Fix NPE in matchAnyCertification when entity is null#26904
Merged
sonika-shah merged 10 commits intomainfrom Apr 2, 2026
Merged
Fix NPE in matchAnyCertification when entity is null#26904sonika-shah merged 10 commits intomainfrom
sonika-shah merged 10 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a NullPointerException in backend policy evaluation when matchAnyCertification is evaluated with a ResourceContext whose getEntity() is null, and adds regression coverage to prevent recurrence.
Changes:
- Add an explicit null-guard for
resourceContext.getEntity()inRuleEvaluator.matchAnyCertification. - Add unit tests covering
nullentity andnullresource context scenarios formatchAnyCertification. - Add an integration test intended to reproduce the policy-evaluation NPE path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java | Adds a null check for resourceContext.getEntity() before accessing certification. |
| openmetadata-service/src/test/java/org/openmetadata/service/security/policyevaluator/RuleEvaluatorTest.java | Adds unit tests ensuring matchAnyCertification returns false when entity/context is null. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/QueryVisibilityPolicyIT.java | Adds an integration test for matchAnyCertification policy evaluation regression coverage. |
aji-aju
approved these changes
Apr 2, 2026
Code Review ✅ ApprovedFixes null pointer exception in matchAnyCertification when entity parameter is null. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
Contributor
|
Changes have been cherry-picked to the 1.12.5 branch. |
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 2, 2026
* Fix NPE in matchAnyCertification when entity is null * fix QueryVisibilityPolicyIT test * fix QueryVisibilityPolicyIT test * fix QueryVisibilityPolicyIT test - address feedback * fix QueryVisibilityPolicyIT test - address feedback * address feedback --------- Co-authored-by: Mohit Yadav <105265192+mohityadav766@users.noreply.github.com> (cherry picked from commit 7c7ba41)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Describe your changes:
Fixes #26875
Summary
matchAnyCertificationinRuleEvaluatorthrew aNullPointerExceptionwhenResourceContext.getEntity()returned null (e.g. Settings, Team, or list operations).Optional.ofNullable(resourceContext.getEntity().getCertification())NPE'd on the.getCertification()call beforeOptional.ofNullablecould do anything — Javaevaluates the argument first.
getEntity(), consistent withisReviewer()andhasDomain()in the same class which already have this check.
Test plan
test_matchAnyCertification_nullEntityandtest_matchAnyCertification_nullResourceContextinRuleEvaluatorTesttest_matchAnyCertification_noCertificationOnEntityinQueryVisibilityPolicyIT— creates a policy withmatchAnyCertificationcondition,assigns it to a user, then GETs a table with no certification (the exact repro path)
RuleEvaluatorTesttests passType of change:
Checklist:
Fixes <issue-number>: <short explanation>