Skip to content

Conversation

@perdasilva
Copy link
Contributor

Description

The watchNamespace configuration parameter was not being validated to check if it is a valid kubernetes namespace. In bundles that support single namespace install modes this can lead to bad namespaces not getting rejected during bundle configuration validation.

Changes:

  • Updates the error formatting function to handle min/maxLength and pattern errors
  • Removes the hardcoded watchNamespace field name from the format errors
  • Adds min/maxLength and pattern to watchNamespace definition
  • Adds additional unit test to validate namespace format is being checked

Note: The jsonschema library does not seem to collect format and other errors. To keep things simple for now, I've avoided adding namespace format checks to the custom single- ownnamespace formats.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

Copilot AI review requested due to automatic review settings January 29, 2026 15:33
@netlify
Copy link

netlify bot commented Jan 29, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 6e173e7
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/697cb7f9bf5f8a0008ec77a9
😎 Deploy Preview https://deploy-preview-2468--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

installNamespace: "install-ns",
expectedErrSubstrings: []string{
"field \"watchNamespace\"",
"must match pattern \"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

IHMO: We should use machinary lib instead of regex here
That has a func to validate it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we're using a jsonschema to validate input, shouldn't we rely as much as possible on what it offers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the regex from that lib though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keep in mind the mental model is: bundle provides jsonschema, olm validates user input against jsonschema. So, we should use custom formats sparingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine 👍 fair enough

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds validation for the watchNamespace configuration parameter to ensure it conforms to Kubernetes namespace naming rules. The changes address a gap where invalid namespace names were not being rejected during bundle configuration validation, particularly for bundles with single namespace install modes.

Changes:

  • Added minLength, maxLength, and pattern validation to the watchNamespace schema definition
  • Enhanced error formatting to handle pattern, minLength, and maxLength validation errors with type-based matching instead of string matching
  • Added test cases to verify namespace format validation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
internal/operator-controller/rukpak/bundle/registryv1.go Added namespace validation constraints (pattern, min/maxLength) to watchNamespace schema; converted exported constant to unexported
internal/operator-controller/config/config.go Refactored error formatting to use type-based error kind matching; removed invalid value display from custom format validator error messages; added handlers for pattern, minLength, and maxLength errors
internal/operator-controller/config/error_formatting_test.go Added test cases for namespace pattern validation and updated expected error messages to match new format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@perdasilva perdasilva force-pushed the fix-namespace-format-validation branch from a8bf0f3 to 650719c Compare January 29, 2026 16:00
Copilot AI review requested due to automatic review settings January 29, 2026 16:14
@perdasilva perdasilva force-pushed the fix-namespace-format-validation branch from 650719c to 6c0fd75 Compare January 29, 2026 16:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@perdasilva perdasilva force-pushed the fix-namespace-format-validation branch from 6c0fd75 to a284284 Compare January 29, 2026 16:50
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 80.39216% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.48%. Comparing base (46f9978) to head (6e173e7).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/operator-controller/config/config.go 65.51% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2468      +/-   ##
==========================================
- Coverage   69.52%   69.48%   -0.05%     
==========================================
  Files         102      102              
  Lines        8231     8249      +18     
==========================================
+ Hits         5723     5732       +9     
- Misses       2056     2063       +7     
- Partials      452      454       +2     
Flag Coverage Δ
e2e 46.95% <54.90%> (-0.01%) ⬇️
experimental-e2e 13.34% <0.00%> (-0.09%) ⬇️
unit 57.52% <37.25%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@perdasilva perdasilva force-pushed the fix-namespace-format-validation branch from a284284 to 228d5ab Compare January 30, 2026 08:24
Copilot AI review requested due to automatic review settings January 30, 2026 08:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
@perdasilva perdasilva force-pushed the fix-namespace-format-validation branch from f790949 to 6e173e7 Compare January 30, 2026 13:53
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2026
@openshift-ci
Copy link

openshift-ci bot commented Jan 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit 4d4f894 into operator-framework:main Jan 30, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants