Skip to content

fix(auth): Skip token refresh attempt when cluster has auth disabled - #1136

Merged
JashG merged 7 commits into
mainfrom
jgulabrai/auth-disabled-failure-fix
Aug 7, 2026
Merged

JashG merged 7 commits into
mainfrom
jgulabrai/auth-disabled-failure-fix

Conversation

@JashG

@JashG JashG commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

When an nmp config file contains an OAuthUser from a previous nemo auth login session, but the active cluster has auth disabled, client construction would crash with an opaque UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol error.

Root cause: _resolve_bootstrap was building an OIDCTokenProvider with an empty token_endpoint (what discovery returns for no-auth clusters) and immediately attempting a token refresh against it. The fix adds an early-return in _resolve_bootstrap to skip refreshing the token when auth is disabled.

Before: nemo setup throws an error:

Unexpected error: NeMoPlatform client initialization failed: Request URL is missing an 
'http://' or 'https://' protocol.

After: nemo setup doesn't throw an error and proceeds with the setup flow.

Related Issue

None.

Changes

  • packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py: Added guard in _resolve_bootstrap: when the cluster's discovery endpoint returns auth_enabled=False and no explicit access_token was provided, return a no-auth bootstrap instead of constructing an OIDCTokenProvider with an empty endpoint.
  • packages/nemo_platform_ext/tests/client/test_client.py: Added TestCreateClientOAuthUserAuthDisabledCluster with two regression tests. Fixed six existing tests that were relying on the accidental behavior of a failing discovery call being silently ignored - each now mocks discover_nmp_config to reflect a cluster that actually accepts auth. Renamed test_env_access_token_overrides_user_authtest_explicit_access_token_overrides_config_auth to accurately describe what create_client tests (explicit param, not env var reading).

Type of Change

  • Code change (feature, bug fix, or refactor)

Quality Gates

  • Tests added or updated for changed behavior
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: internal client factory behavior, no user-facing docs surface.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Summary by CodeRabbit

  • Bug Fixes

    • Improved OAuth connection handling when authentication is disabled and no access token is provided.
    • Prevented unnecessary token refreshes and authorization setup in authentication-disabled environments.
    • Preserved existing behavior when an explicit access token is supplied.
    • Maintained authorization with valid stored tokens when configuration discovery fails.
  • Tests

    • Expanded coverage for API-key, override, asynchronous, and OAuth connection scenarios, including authentication-disabled environments and discovery failures.

@JashG
JashG requested review from a team as code owners August 6, 2026 19:25
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a06a9a43-24ad-4330-ae1f-f632d5bbbaa9

📥 Commits

Reviewing files that changed from the base of the PR and between cc923b2 and 90fcea8.

⛔ Files ignored due to path filters (1)
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/client/test_client.py is excluded by !sdk/**
📒 Files selected for processing (1)
  • packages/nemo_platform_ext/tests/client/test_client.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/nemo_platform_ext/tests/client/test_client.py

📝 Walkthrough

Walkthrough

OAuth bootstrap skips token-provider setup when OIDC authentication is disabled and no explicit access token is supplied. Discovery failures retain provider setup. Tests cover these paths and add configuration-discovery mocks across client scenarios.

Changes

OAuth authentication bootstrap

Layer / File(s) Summary
Auth-disabled OAuth fallback
packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py
The factory adds a shared disabled-auth OIDC configuration. OAuth bootstrap skips token-provider setup when authentication is disabled and no explicit token is provided. Discovery failures continue the existing provider flow.
Client authentication regression coverage
packages/nemo_platform_ext/tests/client/test_client.py
Tests cover explicit token overrides, auth-disabled OAuth behavior, discovery-failure handling, and configuration-discovery mocks for synchronous and asynchronous clients.

Sequence Diagram(s)

sequenceDiagram
  participant OAuthBootstrap
  participant OIDCDiscovery
  participant TokenProvider
  OAuthBootstrap->>OIDCDiscovery: Discover OIDC configuration
  OIDCDiscovery-->>OAuthBootstrap: Return disabled-auth configuration or error
  OAuthBootstrap->>TokenProvider: Skip setup when auth is disabled without an explicit token
  OAuthBootstrap->>TokenProvider: Continue setup after discovery failure
Loading

Possibly related PRs

Suggested reviewers: anastasia-nesterenko, mckornfield

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: skipping token refresh when cluster authentication is disabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jgulabrai/auth-disabled-failure-fix

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py`:
- Around line 527-535: The guard around _ResolvedBootstrap must not interpret
_discover_oidc_client_settings exceptions as confirmed no-auth; preserve a
distinct discovery-failure state or fail bootstrap, and only return the no-auth
result when successful discovery confirms auth_enabled=False. Add a regression
test covering a discovery exception with a valid stored token, ensuring OAuth
authentication is not silently removed.
- Around line 527-535: Update the bootstrap resolution flow around the
auth-disabled guard to compute a single effective access-token override that
includes NMP_ACCESS_TOKEN and the explicit access_token value. Use this
effective token for the guard condition and downstream provider-sharing
behavior, preserving the no-auth fallback only when no effective token exists.
Restore coverage for an NMP_ACCESS_TOKEN on auth-disabled clusters.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bfb65645-3532-4a89-9845-51791f108402

📥 Commits

Reviewing files that changed from the base of the PR and between c71ca67 and 0509660.

⛔ Files ignored due to path filters (2)
  • sdk/python/nemo-platform/src/nemo_platform/client/factory.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/client/test_client.py is excluded by !sdk/**
📒 Files selected for processing (2)
  • packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py
  • packages/nemo_platform_ext/tests/client/test_client.py

Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/client/factory.py Outdated

@ironcommit ironcommit 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.

LGTM

JashG added 5 commits August 7, 2026 09:26
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
@JashG
JashG force-pushed the jgulabrai/auth-disabled-failure-fix branch from cc923b2 to 0d668fb Compare August 7, 2026 13:26
@github-actions github-actions Bot added the fix label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 31442/40067 78.5% 63.0%
Integration Tests 18308/38019 48.1% 20.8%

JashG and others added 2 commits August 7, 2026 09:53
NeMoPlatform.__init__ runs a second bootstrap via the SDK factory when
create_client returns http_client=None (the no-auth path). In CI there
is no local server, so the unpatched SDK factory discovery call fails,
falls through to an OIDCTokenProvider with the stored token, and crashes
on refresh. Patch nemo_platform.client.factory.discover_nmp_config in
addition to the ext factory mock so both bootstrap passes see the same
auth_enabled=False response.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
Signed-off-by: Jash Gulabrai <jgulabrai@nvidia.com>
@JashG
JashG added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit a7889a8 Aug 7, 2026
52 checks passed
@JashG
JashG deleted the jgulabrai/auth-disabled-failure-fix branch August 7, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants