Skip to content

[fix] Put the validation error text into "message" - #12

Merged
yalosev merged 1 commit into
mainfrom
fix/validation-error-message
Oct 12, 2026
Merged

yalosev merged 1 commit into
mainfrom
fix/validation-error-message

Conversation

@yalosev

@yalosev yalosev commented Oct 12, 2026

Copy link
Copy Markdown
Member

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 from message, 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) calls ctx.output.validations.error(str(e)) for every exception a ValidationWebhook handler raises. With this bug such denials carry no explanation.

Tests

tests/validations_test.py covers allow, allow with warnings, deny and error. The error case fails on the previous code. pytest passes, 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.

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>
@yalosev
yalosev merged commit 3fd4ff5 into main Oct 12, 2026
2 checks passed
@yalosev
yalosev deleted the fix/validation-error-message branch October 12, 2026 09:16
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.

1 participant