-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
The semicolon
is no longer a supported separator as described in golang.org/issue/25192
In the Java gapic-generator, the query parameter json;enum-encoding=int
is appended to requests when the numeric enum feature is enabled. See HttpJsonServiceStubClassComposer for reference. This results in the following error message from the showcase server:
{"error":{"code":400,"message":"unrecognized request: GET \"/v1beta1/echo:echo?$alt=json;enum-encoding%3Dint\"","details":null,"Body":"","Header":null,"Errors":null}}
2023/01/25 13:18:00 Received POST request matching '/v1beta1/echo:echo': "/v1beta1/echo:echo?$alt=json;enum-encoding%3Dint"
2023/01/25 13:18:00 urlPathParams (expect 0, have 0): map[]
2023/01/25 13:18:00 error in query string: invalid semicolon separator in query
2023/01/25 13:18:00 http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192
See also related issue in gapic-generator-java: googleapis/sdk-platform-java#1187
Additionally, replacing;
with %3b
according to the guidelines results in the parameter being double escaped:
2023/01/27 17:35:50 Received POST request matching '/v1beta1/echo:echo': "/v1beta1/echo:echo?$alt=json%253benum-encoding%3Dint"
2023/01/27 17:35:50 urlPathParams (expect 0, have 0): map[]
2023/01/27 17:35:50 error in query string: unhandled value "json%3benum-encoding=int" for system parameter "$alt"
The issue appears to be rooting from url.ParseQuery
. According to the function's Go documentation:
Query is expected to be a list of key=value settings separated by ampersands. A setting without an equals sign is interpreted as a key set to an empty value. Settings containing a non-URL-encoded semicolon are considered invalid.
A few open-ended questions to possibly help address this:
- Could this be resolved by url encoding the query parameter before calling
url.ParseQuery
viaURLEncoder.encode(queryString)
? - Alternatively, is it possible for systemparam.go to accept
&
as a separator?
Thank you!
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.