Fix empty query parameters in expand_params method
#18979
+3,320
−3,686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, there was no distinction between parameters passed to the backend with an empty value.
For example, when parsing the query string
?expand, Rails would include the key but with a nil value in theparamshash. When this hash was later serialized back into a query string using the.to_querymethod, it erroneously resulted in?expand=.This incorrect modification caused the backend to throw a 400 error.
This commit resolves the issue by splitting query parameters into two distinct groups of parameters and handling them differently.
See #18976 and #18978.
See previous implementation, where this case was taken in account:
open-build-service/src/api/app/lib/backend/connection.rb
Lines 95 to 97 in fc622a8
Reference: https://api.rubyonrails.org/v7.2.3/classes/Hash.html#method-i-to_query