Skip to content

Fix gh-11740: Add missing null check in validateProfileId()#11741

Open
abhu85 wants to merge 1 commit intoapache:masterfrom
abhu85:gh-11740-profile-id-null-check
Open

Fix gh-11740: Add missing null check in validateProfileId()#11741
abhu85 wants to merge 1 commit intoapache:masterfrom
abhu85:gh-11740-profile-id-null-check

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Feb 24, 2026

Summary

Add missing null check before validProfileIds.contains(id) in validateProfileId() to prevent NullPointerException and make it consistent with validateCoordinateId().

Problem

In impl/maven-impl/.../DefaultModelValidator.java, the validateProfileId() method calls validProfileIds.contains(id) without checking if id is null first.

Since validProfileIds uses ConcurrentHashMap.newKeySet() which doesn't allow null keys, a null profile ID would cause a NullPointerException instead of a proper validation error message.

Inconsistency in the same file:

// Line 1744 - validateCoordinateId() has null check ✓
if (id != null && validCoordinatesIds.contains(id)) {

// Line 1795 - validateProfileId() was missing null check ✗
if (validProfileIds.contains(id)) {  // NPE if id is null

Solution

Add the same null check pattern used in validateCoordinateId():

if (id != null && validProfileIds.contains(id)) {

Test Plan

  • mvn spotless:apply - formatting verified
  • mvn test -pl impl/maven-impl -Dtest=DefaultModelValidatorTest - all 76 tests pass

Compatibility

This is a backward-compatible fix. Null profile IDs will now be properly handled by validateStringNotEmpty() instead of throwing NPE.

Fixes #11740


🤖 Generated with Claude Code

The validateProfileId() method was missing a null check before calling
validProfileIds.contains(id). Since validProfileIds uses
ConcurrentHashMap.newKeySet() which doesn't allow null keys, a null
profile ID would cause a NullPointerException instead of a proper
validation error.

This makes validateProfileId() consistent with validateCoordinateId()
which already has the null check.

Fixes apache#11740

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abhu85 abhu85 force-pushed the gh-11740-profile-id-null-check branch from e3980bd to 273ccc9 Compare February 26, 2026 17:47
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.

Missing null check in DefaultModelValidator.validateProfileId() can cause NPE

1 participant