-
Notifications
You must be signed in to change notification settings - Fork 337
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
HTTP: Added variable validation to the response_headers option #1191
Conversation
I don't think the word "previous" is actually used in error messages, and it would be confusing to introduce it now. Something like this would be far more useful. Now that we have route logging, it would be great to see the route URI show up in the config-apply error messages. {
"error": "Invalid configuration.",
"detail": "Unknown variable $b in routes/0/action/response_headers/a."
} |
Hi @lcrilly,
I agree to display describable error messages whenever possible, but it's another separate topic than the PR.
Take the below configuration as an example,
It shows an error like this.
It's a general handling internally and happens in the control process that validates configuration before applying it.
This happened in the router process when it was applied.
This is what the patch did, it's similar to this commit. 49aee67 |
In my experience "previous configuration is invalid" is shown when Unit starts and tries to apply the configuration in the state directory. When applying configuration to a running instance I see
Are you only addressing the startup case with this PR? That seems like an incomplete approach. |
I see what you mean.
It's both for startup case and control API. Sorry that I didn't test this case, I just followed the code and thought it was general.
vs
As you see, we should validate the configuration in the controller process so that it can show the exact error as much as possible. |
Variables don't contain spaces so why would we put (escaped) quotes ( |
Yes, it doesn't.
TBH, both are fine for me. We could improve with another patch and it needs to be general for all variables. |
The |
I think this patch is fine for what it's doing. The other suggestions would likely be a larger more intrusive patch. |
Yep, they can be separated patches if needed.
JSON does provide the function of escaping strings in Unit configuration, but in this case of variables error message, it's assembled manually.
|
…ers" For more information please see nginx#1191
This is to improve error messages for response headers configuration. Take the configuration as an example: { "response_headers": { "a": "$b" } } Previously, when applying it the user would see this error message: failed to apply previous configuration After this change, the user will see this improved error message: the previous configuration is invalid: Unknown variable "b" in the "a" value
…ers" For more information please see nginx#1191
…ers" For more information please see #1191
…ers" For more information please see nginx#1191
This is to improve error messages for response headers configuration. Take the configuration as an example:
Previously, when applying it the user would see this error message:
After this change, the user will see this improved error message: