Repository navigation
fix(sdk/go): use the CLI oidc_token.json format #4830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lunarwhite
wants to merge
1
commit into
NVIDIA:main
Choose a base branch
from
lunarwhite:fix/4508-go-sdk-oidc-token-format/lunarwhite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+450
−364
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "access_token": "conformance-access-token", | ||
| "refresh_token": "conformance-refresh-token", | ||
| "expires_at": 4102444800, | ||
| "issuer": "https://issuer.example.com", | ||
| "client_id": "openshell-cli" | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| SPDX-License-Identifier: Apache-2.0 |
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: During refresh backoff (up to 30s),
GetRequestMetadatareplays the cachedlastErr. After a user follows the new "runopenshell gateway login <name>" hint, a long-running client keeps failing with the stale "expired" message until the backoff window ends, instead of re-reading the freshly writtenoidc_token.json.Why this matters: The backoff delay predates this PR, but the PR adds the login hint and the
lastErrreplay, and together they make the stale message visible to users. Scenario: a client created withgateway.NewClient(auth_mode=oidc) keeps issuing RPCs after the token inoidc_token.jsonexpires. Each faileddiskTokenSource.Token()doubles the backoff (1s, 2s, 4s, up to the 30s cap,auth_refresh.go:122-136), and the error reads "OIDC token for gateway "prod" expired at ...; runopenshell gateway login prod" (gateway/token.go:117-139). The user runs the CLI login, which rewritesoidc_token.jsonwith a valid token. The next RPC lands insidenextRetry, takes the branch at lines 96-104, findsusableCached()false, and returns the same "expired ... run login" error for up to 30s. To reproduce: take theTestResolveAuthProvider_OIDCPicksUpReplacedTokenNearExpirysetup with an expired token, callGetRequestMetadataabout 6 times so the backoff grows, rewrite the file with a fresh token, and call again. Going by the code, that call returns the staleErrTokenLoaderror instead ofBearer token-b.Suggested fix: Since you plan to move the gateway path to refresh in #4514, take this mainly as input for that change. Any one of these closes the gap: skip backoff for the disk source, because re-reading a local file is cheap (for example
RefreshableToken(src, v1.WithMaxBackoff(0))or an internal option); cap the disk-source backoff at about 1s; or mark the replayed error as cached, for examplefmt.Errorf("%w (retrying in %s)", r.lastErr, time.Until(r.nextRetry).Round(time.Second)).Source: gator agent (also flagged by: production agent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion, I've noted this and will include it in #4514. Re-reading the file will prevent the backoff, meaning that only the IdP refresh will be affected. Probably also worth adding this case as a test.