fix(common): properly cast http param values to strings#42643
fix(common): properly cast http param values to strings#42643cexbrayat wants to merge 1 commit intoangular:mainfrom
Conversation
|
Quick comment: from API perspective it looks a bit unusual that the values are always converted to strings, i.e. in the following example: As an API user I may expect the original value to be returned (i.e. Should we consider changing the Note: I'm not sure what the right approach is, just want to check if changing the |
|
@AndrewKushnir Thanks for your feedback. I have no strong opinions on this. This fix is a good first step (as the current behavior is broken), but if the team decides to change the signatures of |
I agree, we will schedule some time at the next framework meeting to discuss the public API for the |
bd73187 to
037931c
Compare
|
The presubmit finished, but failed to report back. There are two legit test failures that exactly test against HttpParams, and are failing for the expected reasons. We'd have to fix those two tests forward along with this. |
Discussed in our team meeting. We should not change the public API of this class to allow non-strings to be returned. The aim of the class is to provide a stringified list of params for HTTP requests, not as a general purpose container for values. |
@cexbrayat thanks for the reply. I've looked at the code once again and found out that the I'm adding the "blocked" label for now due to some failing tests in Google's codebase that would require a cleanup. We'd also need to run a global check in Google's codebase to see if we have more instances. |
|
Is it possible to directly re-encapsulate the native URLSearchParams? Rather than manually maintaining the map. |
|
@HyperLife1119 - do you mean for the |
Yes, but Angular currently does not do this, I want to know the reason. |
|
|
Thanks, I will continue to pay attention to this PR. |
037931c to
e5b5a00
Compare
e5b5a00 to
8da0c36
Compare
|
Global Presubmit (internal-only link). |
|
@AndrewKushnir @cexbrayat Is this something we intend to land in 14? If so, I kicked off a de-flake run of failures from the above TGP. |
|
@dylhunn That was the idea, yes |
|
Looking at the presubmit results, some cleanup in g3 is needed. We're squeaking in a bit late (freeze is Wednesday). Andrew and I will have a look at what's needed, but this may have slipped by us again 🤦 I'll post an update after our rerun finishes. |
Before this commit, when initializing `HttpParams` with:
const body = new HttpParams({fromObject: {b: 2}});
then `body.get('b')` returned `2` instead of `'2'` as expected.
This commit makes sure the values are converted to strings in such cases.
Fixes angular#42641
8da0c36 to
1c311a0
Compare
|
Quick update: we are waiting for some cleanup in Google's codebase to land. After that we'll rerun the necessary tests (TGP) and if everything goes well, we should be able to proceed with the merge of this PR. |
|
I am running another TGP with all g3 patches applied: Edit: Looks like all failures are preexisting. |
|
merge-assistance: we are still waiting for one g3 team to submit the fix we provided. |
|
This PR was merged into the repository by commit 10691c6. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Before this commit, when initializing
HttpParamswith:then
body.get('b')returned2instead of'2'as expected.Fixes #42641
What is the new behavior?
This commit makes sure the values are converted to strings in such cases.
Does this PR introduce a breaking change?
Other information