Skip to content

fix(doctor): apply the ambient-auth exemption to the doctor key check - #4536

Merged
IsmaelMartinez merged 1 commit into
The-PR-Agent:mainfrom
Kiddo4993:fix/issue-4531
Oct 30, 2026
Merged

IsmaelMartinez merged 1 commit into
The-PR-Agent:mainfrom
Kiddo4993:fix/issue-4531

Conversation

@Kiddo4993

@Kiddo4993 Kiddo4993 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

User description

Fixes #4531.

pr-agent doctor failed its key check, and exited with code 1, for Bedrock setups that use IRSA/IMDS. The same happened with Azure. In both cases the model ping succeeded. The cause was that the ambient-auth / custom-endpoint exemption lived only in missing_provider_key_env_vars(), which the GitHub Action runner uses. _check_provider_key(), which doctor uses, did not have it.

Changes

  • Moved the exemption into a helper, _uses_ambient_auth_or_custom_endpoint(provider). It covers azure_ad.client_id, bedrock* / azure* providers, and <provider>.api_base. The rules are unchanged.
  • _check_provider_key() now uses the helper after the "real key found" branch. In those setups it reports no static key for '<provider>' (ambient auth or custom endpoint); ping decides as a passing check, and the ping then decides the result.
  • missing_provider_key_env_vars() now just relies on _check_provider_key(). doctor and the runner share one decision path, so the runner's behaviour stays the same.

Tests

  • Added a parametrized test (Bedrock, Azure): with no static key and a successful ping, doctor exits 0 and reports 3 of 3 checks passed.
  • The existing runner-facing tests (*_defers_to_the_run) and the placeholder / missing-key failure tests for OpenAI are unchanged and should still pass.

Fixes #4531


Happy to adjust anything or close it if it isn't a fit.


PR Type

Bug fix, Tests


Description

  • Fix doctor failures with ambient authentication.

  • Share credential exemptions with GitHub Action checks.

  • Test successful Bedrock and Azure diagnostics.


Diagram Walkthrough

flowchart LR
  doctor["Doctor diagnostics"]
  runner["GitHub Action credential check"]
  check["Shared provider key check"]
  exemption["Ambient authentication or custom endpoint"]
  completion["Model completion determines success"]
  doctor --> check
  runner --> check
  check -- "No static key" --> exemption
  exemption -- "Defer validation" --> completion
Loading

File Walkthrough

Relevant files
Bug fix
doctor.py
Share credential exemptions across doctor and runner         

pr_agent/doctor.py

  • Extract ambient-authentication and custom-endpoint exemptions into
    _uses_ambient_auth_or_custom_endpoint().
  • Apply exemptions in _check_provider_key() after checking for a usable
    static key.
  • Report exempt configurations as passing, leaving authentication
    validation to the model ping.
  • Remove duplicate exemption logic from missing_provider_key_env_vars(),
    preserving runner behavior.
+10/-4   
Tests
test_cli_doctor.py
Cover successful doctor checks with ambient authentication

tests/unittest/test_cli_doctor.py

  • Add parametrized CLI regression coverage for Bedrock and Azure without
    static keys.
  • Verify successful model pings produce exit code zero and three passing
    checks.
  • Assert diagnostic output explains deferred authentication validation.
+14/-0   


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 6,133 in / 355 out / 6,488 total
  • Time cost: 8.2s
  • AI calls: 1

@the-pr-agent-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

4531 - Fully compliant

Compliant requirements:

  • Accept Bedrock ambient authentication without explicit credentials when model completion succeeds.
  • Return exit code 0 for successful ambient-auth diagnostics.
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 7,528 in / 249 out / 7,777 total
  • Time cost: 6.8s
  • AI calls: 1

@the-pr-agent-bot

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 5,506 in / 71 out / 5,577 total
  • Time cost: 4.9s
  • AI calls: 1

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @Kiddo4993 for moving the ambient-auth exemption into a shared helper so doctor no longer fails Bedrock IRSA/IMDS and Azure setups when the ping succeeds, approving and merging.

@IsmaelMartinez
IsmaelMartinez merged commit d8f70d5 into The-PR-Agent:main Oct 30, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor command errors unnecessarily

2 participants