Skip to content

lowercase patch method not permitted on window fetch #305

@blue-hope

Description

@blue-hope

There seems to be an error related to the update resource of google AIP.

As specified in AIP, update resource should be sent by patch method, and gax-nodejs is also supposed to send request to patch.
However, for window fetch https://fetch.spec.whatwg.org/#methods, as you can see here, patch is not allowed as the default specification.

So, I think it would be better to change it to uppercase ‘PATCH’ instead of lowercase ‘patch’, what do you think?

In fact, when I use this library in production it passes 400 Bad Requests. And when I fix the build to use the method with the name "PATCH" in local, got no errors.

Environment details

  • OS: macOS 12.4
  • Node.js version: v18.7.0
  • npm version: v8.15.0
  • google-gax version: 2.30.4

Steps to reproduce

  1. create update resource service
// Updates an existing Resource And Returns the updated Resource.
  rpc UpdateResource(UpdateResourceRequest) returns (Resource) {
    option (google.api.http) = {
      patch: "/api/v1/{resource.name=resources/*}"
      body: "resource"
    };
    option (google.api.method_signature) = "resource,update_mask";
  }
  1. build it with google-gax
  2. use the service
const resourceService = new ResourceServiceClient({
    auth: { getRequestHeaders: async () => ({ authorization: "Bearer abcd" }) },
    fallback: 'rest',
    protocol: 'https',
    apiEndpoint: 'api.end.point',
    port: 443,
});
await resourceService.updateResource(request);

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions