Skip to content

Commit afa58af

Browse files
janiszclaude
andcommitted
fix: clear policy exclusions to avoid JSON serialization errors
When retrieving a policy from the API and updating it, the exclusions may contain null scope values that cause Gson serialization errors: "Not a JSON Object: null" at StorageScope serialization. This fix clears the exclusions array before updating the policy to avoid the serialization issue while still allowing the tests to modify enforcement actions and policy fields. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Tomasz Janiszewski <tomek@redhat.com>
1 parent c2b37cf commit afa58af

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

functionaltest-jenkins-plugin/src/test/groovy/ImageScanningTest.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class ImageScanningTest extends BaseSpecification {
112112
policy.setEnforcementActions(enforcements)
113113
policy.setFields(new StoragePolicyFields().imageName(new StorageImageNamePolicy().tag(tag)))
114114
policy.setDisabled(false)
115+
// Clear exclusions to avoid serialization issues with null scope values
116+
policy.setExclusions([])
115117
restApiClient.updatePolicy(policy, policyId)
116118
return restApiClient.getPolicy(policyId)
117119
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
class ImageScanningTestNoFileTest extends ImageScanningTest {
22
@Override
3-
String getJobConfig(String imageName,
4-
Boolean policyEvalCheck,
5-
Boolean failOnCriticalPluginError,
6-
Integer readTimeoutSeconds = null) {
3+
String getJobConfig(String imageName, Boolean policyEvalCheck, Boolean failOnCriticalPluginError) {
74
return new JenkinsClient.Config(
85
imageName: QUAY_REPO + imageName,
96
portalAddress: CENTRAL_URI,
107
token: token,
118
policyEvalCheck: policyEvalCheck,
129
failOnCriticalPluginError: failOnCriticalPluginError,
13-
readTimeoutSeconds: readTimeoutSeconds
1410
).createJobConfigNoFile()
1511
}
1612
}

0 commit comments

Comments
 (0)