Skip to content

Conversation

@shawkins
Copy link
Collaborator

closes: #3034

Copilot AI review requested due to automatic review settings November 12, 2025 15:05
@openshift-ci openshift-ci bot requested review from csviri and xstefank November 12, 2025 15:05
Copilot finished reviewing on behalf of shawkins November 12, 2025 15:06
Copy link

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 fixes a NullPointerException in the SSA (Server-Side Apply) based Kubernetes resource matcher when processing managed fields that reference collections that are null or missing in the actual resource. The fix adds null checks before dereferencing list values in two key methods.

Key changes:

  • Added null check in handleListKeyEntrySet to prevent NPE when actualValueList is null
  • Added null check in handleSetValues to prevent NPE when values is null
  • Added test case with a StatefulSet containing managed fields that reference missing values

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
SSABasedGenericKubernetesResourceMatcher.java Added null checks in handleListKeyEntrySet and handleSetValues methods to prevent NPE when referenced collections are missing
SSABasedGenericKubernetesResourceMatcherTest.java Added test case statefulSetWithMissingManagedField to verify matching works when managed fields reference missing values
statefulset-with-managed-fields-missing.yaml Added test resource file containing a StatefulSet with managed fields that reference potentially missing values

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


if (values == null) {
continue;
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

After adding the null check for values at line 404-406, accessing values.get(0) at line 408 can still throw an IndexOutOfBoundsException if the list is empty. Consider adding a check for values.isEmpty() before accessing the first element.

Suggested change
}
}
if (values.isEmpty()) {
continue;
}

Copilot uses AI. Check for mistakes.
closes: operator-framework#3034

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@csviri csviri merged commit 6eb2486 into operator-framework:main Nov 12, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in ssa matching when resource claim is missing in the spec

3 participants