fix(auth): add missing @Nullable annotations across credential types and providers - #14153
Closed
lqiu96 wants to merge 1 commit into
Closed
fix(auth): add missing @Nullable annotations across credential types and providers#14153lqiu96 wants to merge 1 commit into
lqiu96 wants to merge 1 commit into
Conversation
This was referenced Aug 20, 2026
Contributor
There was a problem hiding this comment.
Code Review
This pull request systematically adds @Nullable annotations across various credential classes, builders, and utility methods in the google-auth-library-java library to improve nullness analysis and JSpecify compliance. The review feedback points out a few instances in ExternalAccountCredentials, GoogleCredentials, and UserCredentials where the @Nullable annotation was placed before the method modifiers instead of directly on the return type. Correcting these placements will ensure consistency with the rest of the codebase and proper JSpecify compliance.
| return tokenUrl; | ||
| } | ||
|
|
||
| @Nullable |
Contributor
There was a problem hiding this comment.
| * | ||
| * @return the project id for a Credential type | ||
| */ | ||
| @Nullable |
Contributor
| * | ||
| * @return refresh token | ||
| */ | ||
| @Nullable |
Contributor
lqiu96
force-pushed
the
fix_auth_issue_14147_audit
branch
from
August 20, 2026 20:54
e42cd96 to
4d28828
Compare
lqiu96
force-pushed
the
fix_auth_credential_types_nullability
branch
from
August 20, 2026 20:55
a364201 to
fbe5519
Compare
lqiu96
force-pushed
the
fix_auth_issue_14147_audit
branch
from
August 20, 2026 21:03
c51c2b2 to
be8b8db
Compare
lqiu96
force-pushed
the
fix_auth_credential_types_nullability
branch
from
August 20, 2026 21:04
fbe5519 to
f0b8fc9
Compare
lqiu96
added a commit
that referenced
this pull request
Aug 20, 2026
…14150) This PR is **part 1 of 3** in a stacked series of JSpecify nullability fixes for `google-auth-library-java`: 1. **This PR (#14150)**: `fix(auth): fix JSpecify nullability in UserAuthorizer and TokenStore` (resolves #14147) 2. #14153: `fix(auth): add missing @nullable annotations across credential types and providers` 3. #14154: `fix(auth): annotate builder fields, setters, and getters as @nullable across credential builders` --- Fixes #14147 ### Description In `google-auth-library-java`, classes were recently annotated with `@NullMarked` at the class level. This PR specifically addresses the incompatibilities reported in #14147: 1. **`TokenStore#load` and `MemoryTokensStorage#load`**: Annotates the return type of `load(String id)` with `@Nullable`, as `null` is the expected result when no token data is found for a given identifier. 2. **`UserAuthorizer#getAuthorizationUrl` and `UserAuthorizer#getAndStoreCredentialsFromCode`**: Annotates the `baseUri` parameter with `@Nullable` across `getAuthorizationUrl`, `getAndStoreCredentialsFromCode`, `getCredentialsFromCode`, `getTokenResponseFromAuthCodeExchange`, and `getCallbackUri`, as `baseUri` is optional and only required when using relative callback URIs. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.
This PR is part 2 of 3 in a stacked series of JSpecify nullability fixes for
google-auth-library-java:fix(auth): fix JSpecify nullability in UserAuthorizer and TokenStore(resolves JSpecify incompatibility #14147)fix(auth): add missing @Nullable annotations across credential types and providersfix(auth): annotate builder fields, setters, and getters as @Nullable across credential buildersDescription
Following the migration of
google-auth-library-javato@NullMarked, an audit of all credential types, credential providers, and token utilities identified several methods that can accept or returnnullin standard usage patterns.This PR adds
@Nullableannotations to the following non-builder surfaces:IdTokenProvider:targetAudienceparameter inidTokenWithAudience(...)OptionandOption#getOptionTargetAudience()return type.UserAuthorizer:getCredentialsreturn type,getCredentialsFromCallbackparameters,getAuthorizationUrlparameters (userId,state).UserCredentials: constructorclientIdandclientSecretparameters (and corresponding getter returns), which are nullable for 3-legged scenarios and user credential definitions.ServiceAccountCredentials/ServiceAccountJwtAccessCredentials: nullableserviceAccountUserconstructor parameter and getters,privateKeyId,privateKey,clientEmail,clientIdwhere optional.ExternalAccountCredentials& subclasses (AwsCredentials,IdentityPoolCredentials,PluggableAuthCredentials,ExternalAccountAuthorizedUserCredentials): nullable constructor parameters and getters for optional parameters (workforcePoolUserProject,serviceAccountImpersonationUrl,quotaProjectId,subjectToken, etc.).DownscopedCredentials&ImpersonatedCredentials: nullable optional fields and constructors.GdchCredentials: nullable constructor parameters and getters for optional endpoints/tokens.OAuth2CredentialsWithRefresh,RefreshHandler,DefaultTokenRefresher,SecureSessionAgent.