Skip to content

CNF-25115: Include supported values in validation error messages#440

Open
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:improve-validation-error-messages
Open

CNF-25115: Include supported values in validation error messages#440
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:improve-validation-error-messages

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • When users pass unsupported args, env vars, labels, or resources to the CertManager CR, the validation error now lists the supported values so they can self-correct without consulting documentation
  • Updated all 4 validation functions in deployment_overrides_validation.go

Before

validation failed due to unsupported arg "--foo"="bar"

After

validation failed due to unsupported arg "--foo"="bar"; supported args are: --acme-http01-solver-nameservers, --dns01-recursive-nameservers, --v, -V, ...

Test plan

  • go test ./pkg/controller/certmanager/... passes (all validation tests updated)
  • make lint clean (no new issues)
  • CI e2e tests pass

Summary by CodeRabbit

  • Improvements
    • Enhanced validation error messages to include the full set of supported values for invalid container arguments, environment variables, pod label keys, and resource request/limit configurations.
    • Expanded and updated validation test coverage to verify the improved error details across multiple configuration paths and edge cases.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@sebrandon1: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

  • When users pass unsupported args, env vars, labels, or resources to the CertManager CR, the validation error now lists the supported values so they can self-correct without consulting documentation
  • Updated all 4 validation functions in deployment_overrides_validation.go

Before

validation failed due to unsupported arg "--foo"="bar"

After

validation failed due to unsupported arg "--foo"="bar"; supported args are: --acme-http01-solver-nameservers, --dns01-recursive-nameservers, --v, -V, ...

Test plan

  • go test ./pkg/controller/certmanager/... passes (all validation tests updated)
  • make lint clean (no new issues)
  • CI e2e tests pass

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fbf2f6eb-0a6f-4b82-8e2b-98c1445c34c2

📥 Commits

Reviewing files that changed from the base of the PR and between a8b2d20 and 7a29096.

📒 Files selected for processing (2)
  • pkg/controller/certmanager/deployment_overrides_validation.go
  • pkg/controller/certmanager/deployment_overrides_validation_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/controller/certmanager/deployment_overrides_validation.go

Walkthrough

Validation errors now append supported-value lists for unsupported container args, environment variables, pod labels, and resources. Tests cover expanded messages across controller, webhook, and cainjector override validation.

Changes

Deployment override validation

Layer / File(s) Summary
Supported values in validation errors
pkg/controller/certmanager/deployment_overrides_validation.go
Adds comma-joined supported-value lists to unsupported argument, environment variable, label, and resource errors.
Expanded validation coverage
pkg/controller/certmanager/deployment_overrides_validation_test.go
Adds environment-variable validation cases and updates resource and container-argument expectations, including restricted --v, -V cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: bharath-b-rh, mytreya-rh

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: validation errors now include supported values.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No Ginkgo titles or dynamic values found; all test/subtest names are static string literals.
Test Structure And Quality ✅ Passed These are focused table-driven Go tests (not Ginkgo), with helper-managed cleanup/timeouts and no leaked cluster resources or indefinite waits.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changes are plain Go unit tests in pkg/controller/certmanager with no MicroShift-only API or feature usage.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only unit tests and validation messages changed; no new Ginkgo e2e specs or SNO-sensitive multi-node assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only validation error strings and test expectations changed; no node selectors, affinity, replicas, PDBs, or topology-aware scheduling logic were added.
Ote Binary Stdout Contract ✅ Passed Only fmt.Errorf message changes and added tests; no main/init/TestMain/suite setup or stdout writes were introduced in the changed files.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; the changes are unit tests in pkg/controller/certmanager with no external connectivity or IPv4-only networking assumptions.
No-Weak-Crypto ✅ Passed Touched files only change validation error text and tests; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed PR only changes Go validation code/tests; no manifests or privilege-related settings (privileged, hostPID/Network/IPC, SYS_ADMIN, root, allowPrivilegeEscalation) were added.
No-Sensitive-Data-In-Logs ✅ Passed No logging was added; the changes only return validation errors, so nothing new exposes sensitive data in logs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign swghosh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sebrandon1 sebrandon1 changed the title NO-JIRA: Include supported values in validation error messages CNF-25115: Include supported values in validation error messages Jun 16, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 16, 2026

Copy link
Copy Markdown

@sebrandon1: This pull request references CNF-25115 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • When users pass unsupported args, env vars, labels, or resources to the CertManager CR, the validation error now lists the supported values so they can self-correct without consulting documentation
  • Updated all 4 validation functions in deployment_overrides_validation.go

Before

validation failed due to unsupported arg "--foo"="bar"

After

validation failed due to unsupported arg "--foo"="bar"; supported args are: --acme-http01-solver-nameservers, --dns01-recursive-nameservers, --v, -V, ...

Test plan

  • go test ./pkg/controller/certmanager/... passes (all validation tests updated)
  • make lint clean (no new issues)
  • CI e2e tests pass

Summary by CodeRabbit

  • Improvements
  • Validation error messages now include the complete list of supported values when invalid container arguments, environment variables, pod labels, or resource configurations are provided, making it easier to identify valid options during configuration.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 18, 2026
@sebrandon1
sebrandon1 force-pushed the improve-validation-error-messages branch from 6d0d9e9 to 0d543d2 Compare June 24, 2026 19:51
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 24, 2026
@sebrandon1
sebrandon1 force-pushed the improve-validation-error-messages branch from 0d543d2 to 7739a23 Compare July 6, 2026 16:17
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the improve-validation-error-messages branch from 7739a23 to c58c31c Compare July 13, 2026 17:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/controller/certmanager/deployment_overrides_validation_test.go`:
- Line 75: Update the relevant test cases in the deployment override validation
tests to assert the complete error message: include the
supported-environment-variable list suffix for the controller and assert the
expected empty-list formatting for webhook and cainjector. Replace the partial
“unsupported env var” expectations in each affected wantErrMsg entry while
preserving the existing validation scenarios.
- Line 194: Update the wantErrMsg assertions in the deployment validation cases
around the supported-label checks to include the expected supported-label
suffix, not just “unsupported label.” Apply the corresponding expected
supported-values text consistently to the cases at the referenced assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 46166aa0-9d45-43e0-989c-51b1ce9ff627

📥 Commits

Reviewing files that changed from the base of the PR and between c58c31c and a8b2d20.

📒 Files selected for processing (1)
  • pkg/controller/certmanager/deployment_overrides_validation_test.go

},
},
deploymentName: certmanagerControllerDeployment,
wantErrMsg: "unsupported env var",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the supported environment-variable lists.

These cases only check "unsupported env var", so removing supported env vars are: ... would not fail the tests. Assert the full supported-list suffix for controller and the empty-list behavior for webhook/cainjector.

Also applies to: 90-90, 105-105

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/controller/certmanager/deployment_overrides_validation_test.go` at line
75, Update the relevant test cases in the deployment override validation tests
to assert the complete error message: include the supported-environment-variable
list suffix for the controller and assert the expected empty-list formatting for
webhook and cainjector. Replace the partial “unsupported env var” expectations
in each affected wantErrMsg entry while preserving the existing validation
scenarios.

},
},
deploymentName: certmanagerControllerDeployment,
wantErrMsg: "unsupported label",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the supported label lists.

These checks likewise validate only the generic rejection text, not the PR’s supported-values addition. Include the expected supported-label suffix for each deployment case.

Also applies to: 209-209, 224-224

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/controller/certmanager/deployment_overrides_validation_test.go` at line
194, Update the wantErrMsg assertions in the deployment validation cases around
the supported-label checks to include the expected supported-label suffix, not
just “unsupported label.” Apply the corresponding expected supported-values text
consistently to the cases at the referenced assertions.

Append the list of supported values to all five validation error
messages (args, env vars, labels, resource limits, resource requests)
so users can see what is allowed without checking documentation.

Also fix terminology in validateEnv (was "unsupported arg", now
"unsupported env var").

Add unit tests for the previously untested withContainerEnvValidateHook
and withPodLabelsValidateHook hooks, and strengthen TestValidateResources
to assert error messages include the supported values list.
@sebrandon1
sebrandon1 force-pushed the improve-validation-error-messages branch from a8b2d20 to 7a29096 Compare July 17, 2026 18:49
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/unit 7a29096 link true /test unit

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants