Skip to content

Align dat.uuid.max_number_per_user default with documented value#12150

Open
officialasishkumar wants to merge 1 commit into
cBioPortal:masterfrom
officialasishkumar:fix-dat-uuid-max-tokens-default
Open

Align dat.uuid.max_number_per_user default with documented value#12150
officialasishkumar wants to merge 1 commit into
cBioPortal:masterfrom
officialasishkumar:fix-dat-uuid-max-tokens-default

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

Fix #11907

Describe changes proposed in this pull request:

  • Change the Spring @Value default for dat.uuid.max_number_per_user in UuidDataAccessTokenServiceImpl from -1 to 1, matching the value documented in Authenticating-Users-via-Tokens.md and security.properties-Reference.md.
  • Add a regression test (UuidDataAccessTokenServiceImplDefaultsTest) that verifies the resolved value is 1 when the property is left unset.

The previous default of -1 produced an unusable configuration. UuidDataAccessTokenServiceImpl.createDataAccessToken performs getNumberOfTokensForUsername(username) >= maxNumberOfAccessTokens and then calls revokeOldestDataAccessTokenForUsername whenever the check passes. With maxNumberOfAccessTokens = -1 the inequality is satisfied for any non-negative count, including zero, so the very first token request for a user triggers a revoke against an empty token list and raises IndexOutOfBoundsException from allDataAccessTokens.get(0). Operators who deployed UUID tokens without explicitly setting the property were therefore broken in a way that did not match the docs (which state a default of 1 with permissible values "greater than zero"). Switching the default to 1 gives the "one outstanding token, replaced on new requests" behaviour the docs already promise.

Checks

Any screenshots or GIFs?

Not applicable — backend default value change.

Notify reviewers

Please use git blame and the normal review flow for UuidDataAccessTokenServiceImpl.java (most recent touches to the token service / token configuration). Related issue #11921 covers the analogous mismatch for dat.ttl_seconds and is already assigned, so it is intentionally left out of this PR.

The documented default for dat.uuid.max_number_per_user is 1 (see
docs/deployment/authorization-and-authentication/Authenticating-Users-via-Tokens.md
and docs/deployment/customization/security.properties-Reference.md), but
UuidDataAccessTokenServiceImpl declared the default as -1. With a default of
-1 the limit check getNumberOfTokensForUsername(username) >= maxNumberOfAccessTokens
always evaluates to true for any non-negative count, including zero, which
causes the first token request for a user to attempt revoking the oldest
token of an empty list and throw IndexOutOfBoundsException. Setting the
default to 1 makes the behaviour match the docs (one outstanding token per
user, replaced on each new request) and removes the latent crash.

Add a regression test that verifies the default value resolves to 1 when
the property is not configured, complementing the existing tests that
exercise explicit values of 1 and 5.

Closes cBioPortal#11907
Copilot AI review requested due to automatic review settings May 15, 2026 06:58

Copilot AI left a comment

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.

Pull request overview

This PR aligns the UUID data access token per-user default with the documented configuration value, fixing the mismatch described in #11907.

Changes:

  • Updates dat.uuid.max_number_per_user default from -1 to 1.
  • Adds a regression test verifying the default resolves to 1 when unset.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/main/java/org/cbioportal/legacy/service/impl/UuidDataAccessTokenServiceImpl.java Changes the Spring @Value fallback for UUID token limit to 1.
src/test/java/org/cbioportal/legacy/service/impl/UuidDataAccessTokenServiceImplDefaultsTest.java Adds coverage for the documented default value when the property is not configured.

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

@sonarqubecloud

Copy link
Copy Markdown

@dippindots dippindots requested a review from alisman May 20, 2026 14:38
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.

[BUG] dat.uuid.max_number_per_user default value docs and actual mismatch

2 participants