Skip to content

feat(ISV-6605): Fix static-tests error message on incorrect replaces version#928

Merged
RichardPlesnik merged 1 commit intomainfrom
ISV-6605
Apr 29, 2026
Merged

feat(ISV-6605): Fix static-tests error message on incorrect replaces version#928
RichardPlesnik merged 1 commit intomainfrom
ISV-6605

Conversation

@RichardPlesnik
Copy link
Copy Markdown
Contributor

@RichardPlesnik RichardPlesnik commented Apr 14, 2026

Merge Request Checklists

  • Development is done in feature branches
  • Code changes are submitted as pull request into a primary branch [Provide reason for non-primary branch submissions]
  • Code changes are covered with unit and integration tests.
  • Code passes all automated code tests:
    • Linting
    • Code formatter - Black
    • Security scanners
    • Unit tests
    • Integration tests
  • Code is reviewed by at least 1 team member
  • Pull request is tagged with "risk/good-to-go" label for minor changes

This PR adds existence check validation to propagate readable error message when operator replaces field specifies nonexistent version.

Example of failing static-checks with python traceback before the fix:
redhat-openshift-ecosystem/community-operators-pipeline-preprod#338

Example of fixed error propagation:
RichardPlesnik/community-operators-pipeline-preprod#9

Passing integration tests:
redhat-openshift-ecosystem/operator-pipelines-test#3279

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2026
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Fix replaces version validation and add error handling

🐞 Bug fix 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add validation for non-existent replaces version in bundle checks
  - Prevents KeyError when replaces version doesn't exist
  - Provides clear error message with available versions
• Add comprehensive test for non-existent version replacement scenario
• Code formatting improvements and cleanup
  - Remove extra blank lines in imports
  - Reformat multi-line string literals
• Update dependencies and configuration
  - Upgrade pytest to version 9.0.3
  - Use dynamic Ansible Python interpreter path
Diagram
flowchart LR
  A["Bundle with invalid replaces version"] -->|check_replaces_availability| B["Validate version exists in ver_to_dir"]
  B -->|Version not found| C["Yield Fail with clear error message"]
  B -->|Version found| D["Continue with bundle checks"]
  E["Test case"] -->|Verify error handling| C
Loading

Grey Divider

File Changes

1. operator-pipeline-images/operatorcert/static_tests/community/bundle.py 🐞 Bug fix +8/-0

Add replaces version existence validation

• Add validation check before accessing replaces version in dictionary
• Yield Fail result with descriptive error message when version not found
• Include list of available versions in error message for debugging

operator-pipeline-images/operatorcert/static_tests/community/bundle.py


2. operator-pipeline-images/tests/static_tests/community/test_bundle.py 🧪 Tests +28/-0

Add test for non-existent replaces version

• Add new test function for non-existent version replacement scenario
• Verify error message contains version and available versions list
• Test that Fail result is properly generated

operator-pipeline-images/tests/static_tests/community/test_bundle.py


3. operator-pipeline-images/operatorcert/entrypoints/bulk_retrigger.py Formatting +0/-1

Remove extra blank line in imports

• Remove extra blank line after imports

operator-pipeline-images/operatorcert/entrypoints/bulk_retrigger.py


View more (5)
4. operator-pipeline-images/operatorcert/entrypoints/integration_tests.py Formatting +0/-1

Remove extra blank line in imports

• Remove extra blank line after imports

operator-pipeline-images/operatorcert/entrypoints/integration_tests.py


5. operator-pipeline-images/tests/integration/conftest.py Formatting +4/-8

Reformat multi-line string literals

• Reformat multi-line string literals to single-line format
• Improve code readability and consistency

operator-pipeline-images/tests/integration/conftest.py


6. operator-pipeline-images/tests/test_tekton.py Formatting +2/-4

Reformat multi-line string literals

• Reformat multi-line string literals to single-line format
• Improve code readability and consistency

operator-pipeline-images/tests/test_tekton.py


7. ansible/inventory/group_vars/operator-pipeline.yml ⚙️ Configuration changes +1/-1

Use dynamic Ansible Python interpreter path

• Replace hardcoded Python interpreter path with dynamic Ansible variable
• Use {{ ansible_playbook_python }} for better portability

ansible/inventory/group_vars/operator-pipeline.yml


8. pyproject.toml Dependencies +1/-1

Upgrade pytest dependency version

• Upgrade pytest dependency from 7.3.2 to 9.0.3

pyproject.toml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 14, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2026
@RichardPlesnik RichardPlesnik changed the title [ISV-6605] Fix static-tests error message on incorrect replaces version feat(ISV-6605): Fix static-tests error message on incorrect replaces version Apr 14, 2026
Copy link
Copy Markdown
Contributor

@BorekZnovustvoritel BorekZnovustvoritel left a comment

Choose a reason for hiding this comment

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

LGTM for the changes. Just wondering why this test is applicable in community operators only. Maybe it should be a common test? Let me know if I missed something.

@RichardPlesnik
Copy link
Copy Markdown
Contributor Author

LGTM for the changes. Just wondering why this test is applicable in community operators only. Maybe it should be a common test? Let me know if I missed something.

Good point. I moved it to separate test into common/ folder.

@RichardPlesnik RichardPlesnik changed the title feat(ISV-6605): Fix static-tests error message on incorrect replaces version draft: feat(ISV-6605): Fix static-tests error message on incorrect replaces version Apr 15, 2026
@RichardPlesnik
Copy link
Copy Markdown
Contributor Author

Update: After a discussion with Ales, I moved existing test to common folder to run on all workflows and extended them with bundle existence check.

It was tested on last static-checks run on this PR: RichardPlesnik/community-operators-pipeline-preprod#9

@RichardPlesnik RichardPlesnik changed the title draft: feat(ISV-6605): Fix static-tests error message on incorrect replaces version feat(ISV-6605): Fix static-tests error message on incorrect replaces version Apr 27, 2026
Copy link
Copy Markdown
Contributor

@BorekZnovustvoritel BorekZnovustvoritel left a comment

Choose a reason for hiding this comment

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

I have hard time understanding the test present. Please join my comments with some hints how to understand it better.



@pytest.mark.parametrize(
"bundle_version_annotation,replaces_version_annotation,replaces_csv_value,ocp_range,expected",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The parameters are not easy to understand from their names. What is annotated in the new operator version and what was already present in the repo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These tests were just moved from the previous version from community static-tests, but I can update parameters naming.

@pytest.mark.parametrize(
"bundle_version_annotation,replaces_version_annotation,replaces_csv_value,ocp_range,expected",
[
pytest.param(None, None, None, [], set(), id="No replaces"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this case really return no failure? What is tested here? Is the added bundle valid by other validation standards?

Copy link
Copy Markdown
Contributor Author

@RichardPlesnik RichardPlesnik Apr 28, 2026

Choose a reason for hiding this comment

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

It was moved form the community validation.

Replaces field is not required (and not present in check_required_fields validation). It is valid to omit this field when there is no previous version of the bundle in the channel. In other cases, this would cause dangling bundle and the issue would be caught by check_dangling_bundles static check.

"bundle_version_annotation,replaces_version_annotation,replaces_csv_value,ocp_range,expected",
[
pytest.param(None, None, None, [], set(), id="No replaces"),
pytest.param(None, None, "hello.v0.0.1", [], set(), id="No annotations"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it ok to replace an obsolete version? This would create 2 channel heads in reality, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was moved form the community validation.

It is not replacing obsolete version. Annotations field is not required and when it is missing, it uses all available OCP versions.

Copy link
Copy Markdown
Contributor

@BorekZnovustvoritel BorekZnovustvoritel left a comment

Choose a reason for hiding this comment

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

I won't block you with this, since you are not the original author of the tests that confuse me. I didn't find anything else that would confuse me.

@RichardPlesnik RichardPlesnik merged commit 6d2eea8 into main Apr 29, 2026
20 of 22 checks passed
@RichardPlesnik RichardPlesnik deleted the ISV-6605 branch April 29, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants