Skip to content

fix(auth): provide ADO-specific authentication error message for dev.…#742

Merged
danielmeppiel merged 4 commits intomicrosoft:mainfrom
coakenfold:fix/ado-auth-error-message
Apr 17, 2026
Merged

fix(auth): provide ADO-specific authentication error message for dev.…#742
danielmeppiel merged 4 commits intomicrosoft:mainfrom
coakenfold:fix/ado-auth-error-message

Conversation

@coakenfold
Copy link
Copy Markdown
Contributor

Description

When authentication fails against an Azure DevOps (dev.azure.com) host, the error message incorrectly displayed generic GitHub remediation steps (Set GITHUB_APM_PAT or GITHUB_TOKEN, or run 'gh auth login'). This is confusing for ADO users who need to set ADO_APM_PAT instead.

The fix detects ADO hosts in build_error_context and emits an ADO-specific message:

Azure DevOps authentication required.
Set the ADO_APM_PAT environment variable with a PAT that has Code (Read) scope.

The per-org GitHub token hint is also suppressed for ADO hosts since it doesn't apply.

Fixes #625

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Copilot AI review requested due to automatic review settings April 17, 2026 02:07
@coakenfold
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 improves authentication failure diagnostics for Azure DevOps (dev.azure.com) by emitting ADO-specific remediation guidance (instead of GitHub-centric steps) when no token is available, and suppressing the per-org GitHub token hint for ADO hosts.

Changes:

  • Update AuthResolver.build_error_context() to detect ADO hosts and print an ADO_APM_PAT/Code (Read) guidance message when no token is found.
  • Suppress the per-org GitHub PAT hint for ADO hosts.
  • Add unit tests covering ADO-specific error context behavior.

Reviewed changes

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

File Description
src/apm_cli/core/auth.py Adds ADO-specific error messaging in build_error_context() and suppresses GitHub per-org hint for ADO.
tests/unit/test_auth.py Adds tests to assert ADO-specific remediation text and absence of GitHub-specific hints.

Comment thread tests/unit/test_auth.py
Comment thread tests/unit/test_auth.py
Comment thread src/apm_cli/core/auth.py Outdated
Comment thread src/apm_cli/core/auth.py Outdated
Comment thread src/apm_cli/core/auth.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread tests/unit/test_auth.py
Comment thread tests/unit/test_auth.py
…azure.com PR.2

Implementing Copilot suggestions
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Copy link
Copy Markdown
Collaborator

@sergio-sisternes-epam sergio-sisternes-epam left a comment

Choose a reason for hiding this comment

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

Clean fix! Good use of the existing host_info classification to branch the error context. The test coverage is thorough -- covering both dev.azure.com and legacy visualstudio.com hosts, with-token and no-token paths, and properly asserting that GitHub-specific hints (SAML, gh auth login, per-org PAT) are suppressed for ADO.

Approving -- thanks @coakenfold!

@danielmeppiel danielmeppiel merged commit 73c3dc1 into microsoft:main Apr 17, 2026
6 checks passed
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.

[FEATURE] improve error message for missing auth for ADO repo

4 participants