Skip to content

Invalid semicolon separator in query error when enabling numeric enum feature.  #1255

@mpeddada1

Description

@mpeddada1

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:

  1. Could this be resolved by url encoding the query parameter before calling url.ParseQuery via URLEncoder.encode(queryString)?
  2. Alternatively, is it possible for systemparam.go to accept & as a separator?

Thank you!

cc/ @burkedavison @blakeli0

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions