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

Protect from typos in route definitions #52

Merged
merged 7 commits into from
Feb 4, 2022
Merged

Conversation

PetrHeinz
Copy link

@PetrHeinz PetrHeinz commented Feb 4, 2022

It's quite easy to make a typo in the configuration (eg middleware / middlewares), and some middlewares have effects that are not immediately obvious.

Loading route configs should fail with additional info when such misconfiguration happens, imo. It was surprising that there was a test for allowing extra fields - is there a use case for this?

@PetrHeinz PetrHeinz enabled auto-merge (squash) February 4, 2022 12:00
Copy link
Contributor

@dominikvoda dominikvoda left a comment

Choose a reason for hiding this comment

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

This was there on purpose, platform-backend is using extra fields to do some magic https://github.com/BrandEmbassy/platform-backend/blob/master/application/Configs/api/engager.neon#L41

Maybe we can just introduce alias middleware = middlewares

@PetrHeinz PetrHeinz changed the title Disallow extra fields in config to protect from typos Protect from typos in route definitions Feb 4, 2022
@PetrHeinz
Copy link
Author

PetrHeinz commented Feb 4, 2022

@dominikvoda OK, I get that use case, so I've allowed extra fields back (971b87e), made a supersimple check for that specific typo (bdec72d) and then generalized it to disallowing any config keys that are different, but very similar (1 or 2 changed characters) to the ones we've defined (53e2d9e).

This should provide at least some protection from typos and not interfere with extra fields in other projects.

@PetrHeinz PetrHeinz merged commit 79f9638 into 5.x Feb 4, 2022
@PetrHeinz PetrHeinz deleted the disallow-extra-fields branch February 4, 2022 14:43
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.

3 participants