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

api: discard unknown config proto fields #353

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Conversation

kenjenkins
Copy link
Contributor

Summary

The pomerium-cli api command will persist its state as a protobuf serialized to JSON. If a newer version of pomerium-cli introduces new fields in this protobuf message, an older version of pomerium-cli may not be able to start — currently it will exit if there is any error when unmarshaling this state.

(Ordinarily, adding a field to a proto message is a backwards-compatible change: any software built with the older definition of the proto will generally not notice the new field. However, it looks like the protojson library Unmarshal() method will return an error for any unknown fields present in the JSON data.)

Let's change this behavior, by setting the DiscardUnknown option. This way, an older pomerium-cli binary won't quit on startup if it encounters an unknown option. Instead it will accept all the configuration options it knows about, and ignore the rest. This seems preferably to resetting the configuration entirely.

Related issues

pomerium/desktop-client#319

Checklist

  • reference any related issues
  • updated docs
  • updated unit tests
  • updated UPGRADING.md
  • add appropriate tag (improvement / bug / etc)
  • ready for review

The `pomerium-cli api` command will persist its state as a protobuf
serialized to JSON. If a newer version of pomerium-cli introduces new
fields in this protobuf message, an older version of pomerium-cli may
not be able to start -- currently it will exit if there is any error
when unmarshaling this state.

(Ordinarily, adding a field to a proto message is a backwards-compatible
change: any software built with the older definition of the proto will
generally not notice the new field. However, it looks like the protojson
library Unmarshal() method will return an error for any unknown fields
present in the JSON data.)

Let's change this behavior, by setting the DiscardUnknown option. This
way, an older pomerium-cli binary won't quit on startup if it encounters
an unknown option. Instead it will accept all the configuration options
it knows about, and ignore the rest. This seems preferably to resetting
the configuration entirely.
@kenjenkins kenjenkins requested a review from a team as a code owner October 11, 2023 20:46
@kenjenkins kenjenkins requested a review from wasaga October 11, 2023 20:46
@kenjenkins kenjenkins merged commit a7d0acb into main Oct 11, 2023
@kenjenkins kenjenkins deleted the kenjenkins/allow-unknown branch October 11, 2023 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants