Skip to content

Conversation

@adutra
Copy link
Contributor

@adutra adutra commented Oct 2, 2025

Summary of changes:

  1. Remove the call to ContextLocals (context: Extract interface for RequestIdGenerator #2720 (comment)).
  2. Don't include the exception's message in the response as it can leak details about Polaris internals.
  3. Add a small test for success and failure cases.

UPDATE: we cannot remove ContextLocals, it's used by RealmIdTagContributor.

Summary of changes:

1. Remove the call to ContextLocals (context: apache#2720 (comment)).
2. Don't include the exception's message in the response as it can leak details about Polaris internals.
3. Add a small test for success and failure cases.
@adutra
Copy link
Contributor Author

adutra commented Oct 2, 2025

cc @flyrain @adnanhemani @dimas-b

Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

LGTM

just a few now failing test assertions

@adutra
Copy link
Contributor Author

adutra commented Oct 2, 2025

just a few now failing test assertions

Whoops there were tests for that already 😅 I didn't know.

I will merge the two test classes together.

dimas-b
dimas-b previously approved these changes Oct 2, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Oct 2, 2025
snazy
snazy previously approved these changes Oct 2, 2025
Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

LGTM


@Test
public void testDefaultRealm() {
givenTokenRequest("client1", "secret1")
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between this test and the one above it? Per what I'm seeing, it's the exact same request for different users who both have correct credentials as per L51.

I don't see the require-header variable changing between the two so I'm confused whether this is testing the default header properly or not, as the test names suggest? And if the default header was triggering the IllegalArgumentException, wouldn't that be a 400 Bad Request error code rather than Unauthorized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behavior is different because the default realm is realm1.

In the original test class there were comments explaining this, which I forgot to port over. I will add them now.

@adutra adutra dismissed stale reviews from snazy and dimas-b via 9907935 October 3, 2025 15:26
Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on it, @adutra !

.onItem()
.invoke(realmContext -> rc.setProperty(REALM_CONTEXT_KEY, realmContext))
// ContextLocals is used by RealmIdTagContributor to add the realm id to metrics
.invoke(realmContext -> ContextLocals.put(REALM_CONTEXT_KEY, realmContext))
Copy link
Contributor

@flyrain flyrain Oct 3, 2025

Choose a reason for hiding this comment

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

Trying to understand why RealmIdTagContributor cannot read from the ContainerRequestContext instead of relying on ContextLocals to pass around any object needed for a HttpServerMetricsTagsContributor. Or would it be reasonable to copy the whole rc into a ContextLocals by default? So that any operation on the ContextLocals can use the ContainerRequestContext. Would you mind sharing your thought on it?

Copy link
Contributor

@adnanhemani adnanhemani left a comment

Choose a reason for hiding this comment

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

LGTM - thanks @adutra!

@flyrain flyrain merged commit 10f4bc5 into apache:main Oct 4, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Oct 4, 2025
@flyrain
Copy link
Contributor

flyrain commented Oct 4, 2025

Thanks a lot for working on it @adutra ! Thanks @snazy @dimas-b @adnanhemani for the review!

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.

5 participants