Repository navigation
[fix] Put the validation error text into "message" - #12
Merged
Merged
Conversation
ValidationsCollector.error() used the text itself as the key of the
response: {"allowed": false, "<text>": "Internal webhook error: <text>"}.
shell-operator reads the reason of a denial from "message" and drops the
rest, so the request was denied without a reason. The deckhouse
webhook-operator template calls error() for every exception a
ValidationWebhook handler raises.
tests/validations_test.py covers allow, allow with warnings, deny and
error; the error case fails on the previous code.
Signed-off-by: Yuriy Losev <yuriy.losev@flant.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ValidationsCollector.error()built the response with the text as the key:{"allowed": False, message: f"Internal webhook error: {message}"}so the output was
{"allowed": false, "<text>": "Internal webhook error: <text>"}. shell-operator takes the reason of a denial frommessage, so the request was denied without any reason shown to the user. The key is now"message".Why it matters
The webhook-operator template in deckhouse (
modules/002-deckhouse/images/webhook-handler/operator/internal/controller/templates/validationwebhook.tpl) callsctx.output.validations.error(str(e))for every exception a ValidationWebhook handler raises. With this bug such denials carry no explanation.Tests
tests/validations_test.pycovers allow, allow with warnings, deny and error. The error case fails on the previous code.pytestpasses, 20 tests, on Python 3.8 and 3.12.After the merge, a release (v0.4.12) is needed for deckhouse to pick the fix up in
modules/002-deckhouse/images/webhook-handler/src/requirements.txt.