Skip to content

Commit a945538

Browse files
authored
Guard cnv_current_version against missing csv spec.version (#4003)
##### Short description: spec.version is not a required field in the ClusterServiceVersion schema. If absent, the fixture silently returns None causing unexpected behavior in multiple downstream tests. ##### More details: ##### What this PR does / why we need it: identified during verifying #3984 that we always assume csv has .spec.version , although it exist but since it's optional if it's not there , We should fail early and at right place ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced validation to ensure CSV specification version information is properly defined, raising an error if the required version field is missing rather than silently accepting empty values. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Geetika Kapoor <gkapoor@redhat.com>
1 parent cfdc38b commit a945538

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,10 @@ def cnv_current_version(installing_cnv, csv_scope_session):
956956
if installing_cnv:
957957
return CNV_NOT_INSTALLED
958958
if csv_scope_session:
959-
return csv_scope_session.instance.spec.version
959+
version = csv_scope_session.instance.spec.version
960+
if not version:
961+
raise ValueError("CSV spec.version is missing (field is optional in schema).")
962+
return version
960963

961964

962965
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)