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

Make fly config validate detect unknown fields #3544

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rubys
Copy link
Contributor

@rubys rubys commented May 12, 2024

While we have a number of validators that will check to make sure that field values are correct, we surprisingly do not check to make sure theat field names are correct. Instead we silently ignore fields that have unknown names, often leading to difficult to debug situations.

This change makes use of decoder.DisallowUnknownFields to enable reporting on these errors by fly config validate.

While we have a number of validators that will check to make sure
that field _values_ are correct, we surprisingly do not check to
make sure theat field _names_ are correct.  Instead we silently
ignore fields that have unknown names, often leading to difficult
to debug situations.

This change makes use of `decoder.DisallowUnknownFields` to
enable reporting on these errors by fly config validate.
@rubys
Copy link
Contributor Author

rubys commented May 12, 2024

Amusingly, one of the CI tests is now failing due to an invalid fly.toml:

image

What is the current thinking on validation checks? Adding a validation check can break future deploys. Should it (in general)? Is this specific case different? We can make unknown field validation messages a warning only by capturing and resetting err inside of mapToConfig when running validation as a part of fly deploy.

@dangra
Copy link
Member

dangra commented May 12, 2024

What is the current thinking on validation checks? Adding a validation check can break future deploys.

that is my main concern, every time we change something to be more strict, it breaks users' automated deployments in some way. I think we have to start by showing big warnings first.


decoder := json.NewDecoder(bytes.NewReader(newbuf))
decoder.DisallowUnknownFields()
err = decoder.Decode(cfg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test case and its test file at internal/appconfig/testdata/ ?

I wonder if cfg is "filled" with the rest of the values even when there is an error due to unknown fields.

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.

None yet

2 participants