I'm trying to add in the showcase compliance test suite for Java and I'm running into an issue with the PATCH calls.
Error:
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request
POST http://localhost:7469/v1beta1/repeat:bodypatch
{"error":{"code":400,"message":"unrecognized request: POST \"/v1beta1/repeat:bodypatch\"","details":null,"Body":"","Header":null,"Errors":null}}
at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
at com.google.api.gax.httpjson.HttpRequestRunnable.run(HttpRequestRunnable.java:118)
... 6 more
Java Gax-httpjson's module sends PATCH requests as a POST request with a x-http-method-override: PATCH header, which results in a 400 Bad Request. Looking at the historical reasons for this:
https://github.com/googleapis/gapic-generator-java/blob/c23f981e2ac3c573bed51e725dc7061551179400/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java#L217-L226
// A workaround to support PATCH request. This assumes support of "X-HTTP-Method-Override"
// header on the server side, which GCP services usually do.
//
// Long story short, the problems is as follows: gax-httpjson depends on NetHttpTransport class
// from google-http-client, which depends on JDK standard java.net.HttpUrlConnection, which does
// not support PATCH http method.
//
// It is a won't fix for JDK8: https://bugs.openjdk.java.net/browse/JDK-8207840.
// A corresponding google-http-client issue:
// https://github.com/googleapis/google-http-java-client/issues/167
I believe the mux router setup for bodyPatch to expect a PATCH request
|
router.HandleFunc("/v1beta1/repeat:bodypatch", rest.HandleRepeatDataBodyPatch).Methods("PATCH") |
Possible fix (Thanks to Noah for pointing me here):
- Adding a conditional for PATCH here:
|
for _, handler := range registered { |
|
file.P(` router.HandleFunc(%q, rest.%s).Methods(%q)`, handler.pattern, handler.function, handler.verb) |
|
} |
so it would output
router.HandleFunc("/v1beta1/repeat:bodypatch", rest.HandleRepeatDataBodyPatch).Methods("PATCH", "POST")
Alternatives:
- Does Go Mux support
x-http-method-override?
I'm trying to add in the showcase compliance test suite for Java and I'm running into an issue with the PATCH calls.
Error:
Java Gax-httpjson's module sends PATCH requests as a POST request with a
x-http-method-override: PATCHheader, which results in a 400 Bad Request. Looking at the historical reasons for this:https://github.com/googleapis/gapic-generator-java/blob/c23f981e2ac3c573bed51e725dc7061551179400/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpRequestRunnable.java#L217-L226
I believe the mux router setup for bodyPatch to expect a PATCH request
gapic-showcase/server/genrest/genrest.go
Line 43 in b94ecfc
Possible fix (Thanks to Noah for pointing me here):
gapic-showcase/util/genrest/goviewcreator.go
Lines 292 to 294 in b94ecfc
so it would output
router.HandleFunc("/v1beta1/repeat:bodypatch", rest.HandleRepeatDataBodyPatch).Methods("PATCH", "POST")Alternatives:
x-http-method-override?