Skip to content

Mark user component query parameter as required#18631

Draft
wolfkill wants to merge 1 commit into
apache:masterfrom
wolfkill:fix/user-component-required
Draft

Mark user component query parameter as required#18631
wolfkill wants to merge 1 commit into
apache:masterfrom
wolfkill:fix/user-component-required

Conversation

@wolfkill
Copy link
Copy Markdown
Contributor

Summary

  • mark the component query parameter as required for get, delete, and update User API operations
  • add a reflection-based test to keep the Swagger contract aligned with the required User API parameter

Why

The User API needs component to identify the component-specific user entry. Without this Swagger metadata, the UI can present the field as optional even though the request path requires it.

Fixes #14594

Tests

  • RED: JAVA_HOME=/opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home ./mvnw -pl pinot-controller -am -Dtest=PinotAccessControlUserRestletResourceSwaggerTest -Dsurefire.failIfNoSpecifiedTests=false test failed before the annotation change with component must be marked required on getUser expected [true] but found [false]
  • GREEN: JAVA_HOME=/opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home ./mvnw -pl pinot-controller -am -Dtest=PinotAccessControlUserRestletResourceSwaggerTest -Dsurefire.failIfNoSpecifiedTests=false test
  • git diff --check

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.41%. Comparing base (a762254) to head (21b605f).

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18631      +/-   ##
============================================
+ Coverage     64.40%   64.41%   +0.01%     
  Complexity     1137     1137              
============================================
  Files          3337     3337              
  Lines        206069   206069              
  Branches      32128    32128              
============================================
+ Hits         132710   132731      +21     
+ Misses        62726    62703      -23     
- Partials      10633    10635       +2     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-21 64.41% <ø> (+0.01%) ⬆️
temurin 64.41% <ø> (+0.01%) ⬆️
unittests 64.40% <ø> (+0.01%) ⬆️
unittests1 56.82% <ø> (+<0.01%) ⬆️
unittests2 36.94% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@yashmayya yashmayya left a comment

Choose a reason for hiding this comment

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

Thanks for this! I think it's superseded by your other PR #18606 though — that one makes this same required=true change on all three methods AND adds the runtime guard that actually fixes the NPE. Suggest closing this in favor of #18606 (or rebasing it down). A couple of specifics inline.

@ApiOperation(value = "Get an user in cluster", notes = "Get an user in cluster")
public String getUser(@PathParam("username") String username,
@ApiParam(value = "CONTROLLER|SERVER|BROKER") @QueryParam("component") String componentTypeStr) {
@ApiParam(value = "CONTROLLER|SERVER|BROKER", required = true) @QueryParam("component")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

required = true on a JAX-RS @QueryParam is just Swagger doc metadata — it doesn't make the framework reject a missing component. So the underlying bug still reproduces: with no component, validateComponentType returns null and getUser NPEs on componentType.name(). #18606 adds the actual guard that returns a clean 400.

public class PinotAccessControlUserRestletResourceSwaggerTest {

@Test
public void testUserComponentQueryParamIsRequired()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This reflection test is basically identical to the one #18606 adds, and both PRs edit the same three annotations on the same file — they'll conflict. Another reason to fold this into #18606.

@yashmayya yashmayya added rest-api Related to REST API endpoints auth Related to authentication and authorization labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Related to authentication and authorization rest-api Related to REST API endpoints

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User API: API fails if we skip component field, which is not marked as required

3 participants