Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Proto definitions on the server side breaks client #613

Closed
majst01 opened this issue May 2, 2023 · 3 comments
Closed

Updating Proto definitions on the server side breaks client #613

majst01 opened this issue May 2, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@majst01
Copy link

majst01 commented May 2, 2023

Describe the bug

We updated the proto definition of our API as such that one message contains a additional field like so:

before:

message A {
  string name = 1;
}

after:

message A {
  string name = 1;
  string description = 2;
}

Updating the server side first and not updating the client side (react based) leads to the following error:

ConnectError: [invalid_argument] cannot decode message api.v1.A from JSON: key "description" is unknown
    at LN (connect-error.js:102:16)
    at parse (serialization.js:114:23)

Which breaks the client.

Is there any way to make the client side behave like the go deserializer to simply ignore unknown properties ?

Environment (please complete the following information):

  • @bufbuild/connect version: (for example, 0.8.6)
  • @bufbuild/connect-web version: (for example, 0.8.6)
  • @bufbuild/connect-go version: (for example, 1.7.0) (on the server side)
  • Frontend framework and version: (for example, [email protected])
@majst01 majst01 added the bug Something isn't working label May 2, 2023
@timostamm
Copy link
Member

Hey @majst01, you can set JSON options on the Transport:

https://github.com/bufbuild/connect-es/blob/29dc336bff2246044a9ac331ee70fedcfdcfa46c/packages/connect-web/src/connect-transport.ts#L96-L99

You'll want to set it as { ignoreUnknownFields: true }, following the definition here.

We'll add this to the documentation on connect.build, thanks for opening the issue!

@majst01
Copy link
Author

majst01 commented May 2, 2023

This was fast, thanks a lot @timostamm

@timostamm
Copy link
Member

For posterity: We changed the default behavior in #642 to ignore unknown fields by default. The change was released in v0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants