Skip to content

[BUG] apm install still never asks the Git credential helper for Azure DevOps packages; #2610 covered only the marketplace #3752

Description

Describe the bug

#3008 asked for a Git credential helper fallback for Azure DevOps and was closed as completed by #2610.
On 0.35.1 and main, apm install of an Azure DevOps package still never asks the helper. The
authentication guide
lists path-scoped git credential fill (Git Credential Manager, OS keychain) as the third step for
Azure DevOps Services, after ADO_APM_PAT and the Azure CLI bearer. Without ADO_APM_PAT and a
working az, apm install <Azure DevOps URL> fails validation with all probes failed (marker-file, Contents API, git ls-remote, shallow-fetch), while git clone of the same repository
succeeds with the user's stored credentials. The author of #3008 reported the same on 0.35.0 for a
manifest-driven apm install, which fails in the clone.

This affects users who sign in to Azure DevOps through Git Credential Manager or the keychain and have
no PAT, either without the Azure CLI or with an Azure CLI that cannot issue a token. In the case behind
this report, git clone of a private Azure DevOps repository succeeded without a prompt, while
apm install of a package in it failed with the output shown under Logs.

Root cause: #2610 routed the marketplace client through AuthResolver.try_with_fallback, where
repository-scoped fill lives in _try_ado_credential_fallback
(auth.py#L942-L988).
The install paths for Azure DevOps still resolve one credential up front and retry only with the bearer:

To Reproduce

No Azure DevOps account is needed. A logging credential helper shows whether APM asks for
credentials.

APM=/absolute/path/to/apm   # the release binary
work=$(mktemp -d) && mkdir -p "$work/bin" "$work/fakehome" "$work/proj"
cat > "$work/bin/git-credential-logger" <<'EOF'
#!/bin/sh
echo "helper called: $1" >> "$HOME/helper.log"
[ "$1" = get ] && printf 'username=x\npassword=fake-secret\n'
exit 0
EOF
chmod +x "$work/bin/git-credential-logger"
printf '[credential]\n\thelper = logger\n\tuseHttpPath = true\n' > "$work/fakehome/.gitconfig"
cd "$work/proj"

# 1. APM, with no ADO_APM_PAT and no az on PATH
env -i PATH="$work/bin:/usr/bin:/bin" HOME="$work/fakehome" "$APM" install \
  'https://dev.azure.com/example-org/example-project/_git/example-repo/packages/demo#v1.0.0' \
  --target copilot
cat "$work/fakehome/helper.log"

# 2. APM, with the dependency in apm.yml
printf '%s\n' 'name: proj' 'version: 1.0.0' 'target: copilot' 'dependencies:' '  apm:' \
  '    - https://dev.azure.com/example-org/example-project/_git/example-repo/packages/demo#v1.0.0' \
  > apm.yml
env -i PATH="$work/bin:/usr/bin:/bin" HOME="$work/fakehome" "$APM" install
cat "$work/fakehome/helper.log"

# 3. Git, in the same environment
env -i PATH="$work/bin:/usr/bin:/bin" HOME="$work/fakehome" GIT_TERMINAL_PROMPT=0 \
  git ls-remote https://dev.azure.com/example-org/example-project/_git/example-repo
cat "$work/fakehome/helper.log"

The organization does not exist, so all three commands fail authentication. The difference is that
only Git asks the helper.

Expected behavior

apm install follows the documented chain for Azure DevOps Services: ADO_APM_PAT, then the Azure
CLI bearer, then path-scoped git credential fill, then an error that names the attempted steps. A
user whose git clone works through Git Credential Manager or the keychain can install without a PAT.

Possible fix: route the Azure DevOps validation probes, download_ado_file and the Azure DevOps clone
attempt in CloneEngine through AuthResolver.try_with_fallback with the repository path and
unauth_first=False, as _fetch_ado in marketplace/client.py does since #2610. A recognized
authentication failure then falls through the bearer retry to _try_ado_credential_fallback, which
passes the helper's credential to the operation as an Authorization header. This keeps one resolution
chain in auth.py rather than separate ones in the validation module, the download strategy and the
clone engine, and the exhausted-chain error then names git credential fill among the attempted
steps.

Tests: next to tests/unit/install/test_validation_ado_bearer.py, validate an Azure DevOps virtual
package with ADO_APM_PAT unset, the bearer provider unavailable and resolve_credential_from_git
patched to return a credential: validation sends that credential and passes. With the helper returning
nothing, the error names git credential fill. The same pair for a clone of an Azure DevOps
dependency through CloneEngine.

Alternative: if credential helpers are deliberately excluded from apm install for Azure DevOps,
state that in the authentication guide and in the error, so users stop expecting parity with
git clone.

Out of scope: GitHub, GitLab and generic hosts (#2594). The misleading az login advice when az is
present but fails is a separate problem, which I am reporting separately.

Environment (please complete the following information):

  • OS: macOS 26.7.3 (arm64)
  • Python Version: the standalone release binary (apm-darwin-arm64); main from source with Python 3.12.12
  • APM Version: 0.35.1 (787a97c), the latest release, and main (f574a62)
  • VSCode Version (if relevant): n/a

Logs

Step 1, APM:

[*] Created apm.yml
[i] Targets set: copilot (persisted to apm.yml)
[*] Validating 1 package...
[x]
https://dev.azure.com/example-org/example-project/_git/example-repo/packages/dem
o#v1.0.0 -- all probes failed (marker-file, Contents API, git ls-remote,
shallow-fetch) -- verify the path and ref exist and that your credentials have
read access (run with --verbose for the full probe log)
All packages failed validation. Nothing to install.
[i] Removed apm.yml created by the failed install.

$ cat "$work/fakehome/helper.log"
cat: .../fakehome/helper.log: No such file or directory

With install --verbose, the probe log contains
[x] ls-remote failed via ADO HTTPS without resolved credential.

Step 2, APM with apm.yml (first lines; the az login advice and Last error follow):

[>] Installing dependencies from apm.yml...
[>] Resolving example-repo-demo...
[i] Targets: copilot  (source: apm.yml)
  [x] 1 package failed:
    +- example-repo-demo -- Failed to download dependency
example-org/example-project/example-repo: Failed to clone repository: Failed to
clone repository example-org/example-project/example-repo via plain HTTPS. To
allow cross-protocol fallback (not recommended), pass --allow-protocol-fallback,
set APM_ALLOW_PROTOCOL_FALLBACK=1, or run: apm config set
allow-protocol-fallback true
...
Last error: Cloning into bare repository
'.../bare'...
fatal: Authentication failed for
'https://dev.azure.com/example-org/example-project/_git/example-repo/'
[x] Installation failed with 1 error(s) in 3.7s. No install transaction changes
were committed.

$ cat "$work/fakehome/helper.log"
cat: .../fakehome/helper.log: No such file or directory

Step 3, Git:

fatal: Authentication failed for 'https://dev.azure.com/example-org/example-project/_git/example-repo/'

$ cat "$work/fakehome/helper.log"
helper called: get
helper called: erase

Additional context

The result is the same when az returns a token that Azure DevOps rejects. Validation then reports
but Azure DevOps rejected it (HTTP 401) and still never calls the helper, so the retry after a
rejected PAT or bearer from #2610 does not apply to apm install either.

Tools that wrap apm currently tell Azure DevOps users to set ADO_APM_PAT, even when their Git
credentials already work.

Activity

  1. danielmeppiel commented on Nov 17, 2026

    @danielmeppiel
    Collaborator

    Decision: approve
    Area: project
    Scope: Make AuthResolver.try_with_fallback the single entry point for authenticated Azure DevOps access, backed by a central auth-outcome classifier in core/auth_outcome.py. Route install validation, ref resolution, install preflight, clone, ADO file download and marketplace ADO paths through it so the chain is ADO_APM_PAT, then az bearer, then path-scoped git credential fill. Send helper credentials as Basic username:password, set GCM_INTERACTIVE=0 when not on a TTY or in CI, and let 403 escalate the chain.
    Done when: apm install, install --frozen and update of an Azure DevOps package succeed when only a git credential helper is configured (no ADO_APM_PAT, no az), proven by hermetic unit tests and lifecycle tests against local fixtures, and an architecture guard rejects auth-failure classification or bearer-only escalation outside the auth owner.
    Out of scope: Calling git credential approve or reject; sending X-TFS-FedAuthRedirect; verification against a live Azure DevOps org.
    Review contact: Daniel Meppiel (@danielmeppiel)

  2. danielmeppiel commented on Nov 17, 2026

    @danielmeppiel
    Collaborator

    Context for the scope record above: this is delivered by the 0.36.1 auth track, from a design reviewed and approved by the maintainer on 2026-11-17. The fix gives one owner to the decision "is this response an authentication failure, and which credential comes next", and routes every Azure DevOps and policy egress through it, instead of patching each reported call site. Validation is hermetic (local fixtures and stubs); no live Azure DevOps org was available, so behavior follows the documented Azure DevOps and Git credential contracts.

  3. added
    status/accepted
    on Nov 17, 2026
  4. added a commit that references this issue on Nov 18, 2026
    155a2d7
  5. added 4 commits that reference this issue on Nov 18, 2026
    70554b6
    dbb14fa
    784d778
    f9c34c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/accepted

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions