Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

feat: Print errors of validating settings as multiline#1416

Merged
viccuad merged 2 commits intokubewarden:mainfrom
viccuad:feat/multiline-error
Nov 3, 2025
Merged

feat: Print errors of validating settings as multiline#1416
viccuad merged 2 commits intokubewarden:mainfrom
viccuad:feat/multiline-error

Conversation

@viccuad
Copy link
Copy Markdown
Member

@viccuad viccuad commented Oct 31, 2025

Description

This shows the user multiline errors such as type errors coming from the CEL
policy.

Example:

cel-policy $ kwctl-test run annotated-policy.wasm --allow-context-aware --replay-host-capabilities-interactions test_data/session.yaml --request-path test_data/deployment_gt_max_replicas.json --settings-path test_data/settings_type_error.json
...
Error: Provided settings are not valid: The settings are invalid: 1 error occurred:
        * validations[0].messageExpression: Invalid value: "'Deployment: ' + object.metadata.name + ', namespace: ' + variables.namespaceName + ' - replicas must be no greater than ' + int(variables.maxReplicas)": ERROR: <input>:1:124: found no matching overload for '_+_' applied to '(string, int)'
 | 'Deployment: ' + object.metadata.name + ', namespace: ' + variables.namespaceName + ' - replicas must be no greater than ' + int(variables.maxReplicas)
 | ...........................................................................................................................^:

Instead of:

cel-policy $ kwctl run annotated-policy.wasm --allow-context-aware --replay-host-capabilities-interactions test_data/session.yaml --request-path test_data/deployment_gt_max_replicas.json --settings-path test_data/settings_type_error.json
...
Error: Provided settings are not valid: "The settings are invalid: 1 error occurred:\n\t* validations[0].messageExpression: Invalid value: \"'Deployment: ' + object.metadata.name + ', namespace: ' + variables.namespaceName + ' - replicas must be no greater than ' + int(variables.maxReplicas)\": ERROR: <input>:1:124: found no matching overload for '_+_' applied to '(string, int)'\n | 'Deployment: ' + object.metadata.name + ', namespace: ' + variables.namespaceName + ' - replicas must be no greater than ' + int(variables.maxReplicas)\n | ...........................................................................................................................^:\n\n"

Test

Added e2e testcase.

Additional Information

Tradeoff

Potential improvement

This shows the user multiline errors such as type errors coming from the CEL
policy.

Signed-off-by: Víctor Cuadrado Juan <[email protected]>
Copy link
Copy Markdown
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for having added some e2e tests!

@viccuad
Copy link
Copy Markdown
Member Author

viccuad commented Oct 31, 2025

pushed a ghcr.io/tests/[email protected], set it as public, and we are exercising it now, which may extend the time of the e2e tests.

Edit: the new test takes a bit of time:
test test_run_multiline_error::case_1_admission_review_rejected has been running for over 60 seconds

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.94%. Comparing base (18f9dca) to head (2d07a97).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/command/bench.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1416      +/-   ##
==========================================
+ Coverage   86.74%   86.94%   +0.20%     
==========================================
  Files          34       34              
  Lines        4495     4495              
==========================================
+ Hits         3899     3908       +9     
+ Misses        596      587       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@viccuad viccuad merged commit 14a9959 into kubewarden:main Nov 3, 2025
28 of 31 checks passed
@github-project-automation github-project-automation bot moved this from Pending review to Done in Kubewarden Admission Controller Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Development

Successfully merging this pull request may close these issues.

2 participants