feat(ISV-6605): Fix static-tests error message on incorrect replaces version#928
feat(ISV-6605): Fix static-tests error message on incorrect replaces version#928RichardPlesnik merged 1 commit intomainfrom
Conversation
Review Summary by QodoFix replaces version validation and add error handling
WalkthroughsDescription• 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 Diagramflowchart 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
File Changes1. operator-pipeline-images/operatorcert/static_tests/community/bundle.py
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewⓘ The new review experience is currently in Beta. Learn more |
d88ce04 to
78916be
Compare
78916be to
ed823f4
Compare
ed823f4 to
19926cd
Compare
BorekZnovustvoritel
left a comment
There was a problem hiding this comment.
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. |
1843760 to
ca03f7b
Compare
ca03f7b to
5060635
Compare
|
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 |
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "bundle_version_annotation,replaces_version_annotation,replaces_csv_value,ocp_range,expected", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Should this case really return no failure? What is tested here? Is the added bundle valid by other validation standards?
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Why is it ok to replace an obsolete version? This would create 2 channel heads in reality, no?
There was a problem hiding this comment.
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.
BorekZnovustvoritel
left a comment
There was a problem hiding this comment.
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.
Merge Request Checklists
This PR adds existence check validation to propagate readable error message when operator
replacesfield specifies nonexistent version.Example of failing
static-checkswith 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