Skip to content

[CFS] Fix cargo feed auth for fork builds - #7318

Merged
Daniel Jurek (danieljurek) merged 1 commit into
mainfrom
djurek/cargo-feed-auth
Aug 12, 2026
Merged

[CFS] Fix cargo feed auth for fork builds#7318
Daniel Jurek (danieljurek) merged 1 commit into
mainfrom
djurek/cargo-feed-auth

Conversation

@danieljurek

Copy link
Copy Markdown
Member

cmake build All fails in fork PR validation because cargo cannot read the Cargo index. CargoAuthenticate@0 authenticates with SYSTEM_ACCESSTOKEN, which Azure DevOps does not deliver to fork builds; the task still reports success but writes the anonymous identity, so the failure only surfaces later as a 401/TF400813 from the feed.

Both fixes are ported from azure-sdk-for-rust.

Changes

  • Point config.toml.template at the project-scoped azure-sdk-for-rust-public~force-auth feed
  • Run NuGetAuthenticate@1 before CargoAuthenticate@0 and pass its VSS_NUGET_ACCESSTOKEN in as SYSTEM_ACCESSTOKEN

Split out of #7214, where this was validated as build 6688949: cmake build All 27/27, and CFSClean compliant on every job.

"cmake build All" fails in public PR validation for fork PRs with:

  token rejected for `azure-sdk-for-rust`
  failed to get successful HTTP response from
  .../_packaging/azure-sdk-for-rust/Cargo/index/config.json, got 401
  TF400813: The user 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' is not authorized

Two problems, both already solved in azure-sdk-for-rust
(eng/templates/config.toml.template and
eng/pipelines/templates/steps/use-rust.yml):

1. The feed was the org-scoped azure-sdk-for-rust index with no ~force-auth
   suffix, so Azure DevOps answered the index anonymously. Point at the
   project-scoped public feed with ~force-auth, which reports auth-required and
   is the same crates.io upstream azure-sdk-for-rust consumes.

2. CargoAuthenticate@0 authenticates with SYSTEM_ACCESSTOKEN, which Azure
   DevOps does not deliver to fork builds. The task still reports success but
   writes the anonymous identity, so the failure only surfaces later when cargo
   fetches the index. NuGetAuthenticate@1 authenticates with the build's service
   connection, whose token fork builds do get, and publishes it as
   VSS_NUGET_ACCESSTOKEN; feed that to CargoAuthenticate@0 as SYSTEM_ACCESSTOKEN.

NuGetAuthenticate@1 is declared in cmake-build.yml rather than taken from
nuget-config.yml because archetype-sdk-client.yml includes cmake-build.yml
without it.

Validated on build 6688949: "cmake build All" 27/27 (was 22 failing), 39/40
jobs green, and CFSClean compliant on every job with crates.io traffic gone.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f3a428db-e276-4363-afd9-a944e8533203
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
8 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

Fixes Azure DevOps fork-PR validation failures where Cargo can’t authenticate to the Azure Artifacts Cargo index (401/TF400813) by routing crates.io through the correct “force-auth” feed and ensuring CargoAuthenticate receives a token that is available in fork builds.

Changes:

  • Update the cargo config.toml.template to use the project-scoped azure-sdk-for-rust-public~force-auth feed endpoint.
  • Add NuGetAuthenticate@1 before CargoAuthenticate@0 and pass VSS_NUGET_ACCESSTOKEN as SYSTEM_ACCESSTOKEN to work around missing System.AccessToken in fork builds.

Reviewed changes

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

File Description
eng/templates/config.toml.template Switches the Cargo registry/source replacement to the project-scoped ~force-auth feed to avoid anonymous index access.
eng/pipelines/templates/steps/cmake-build.yml Ensures fork builds get a usable artifacts token via NuGetAuthenticate@1, then supplies it to CargoAuthenticate@0.
Suppressed comments (1)

eng/pipelines/templates/steps/cmake-build.yml:53

  • This task's display name still says azure-sdk-for-rust, but the config points cargo at the azure-sdk-for-rust-public~force-auth feed. Updating the display name will reduce confusion when diagnosing feed/auth issues from logs.
  - task: CargoAuthenticate@0
    displayName: Authenticate cargo to the azure-sdk-for-rust feed
    inputs:
      configFile: $(CargoConfigPath)
    # Workaround issue in public pipelines. Revert when root cause is fixed:

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread eng/pipelines/templates/steps/cmake-build.yml
Comment thread eng/templates/config.toml.template
@danieljurek
Daniel Jurek (danieljurek) merged commit a18563a into main Aug 12, 2026
89 checks passed
@danieljurek
Daniel Jurek (danieljurek) deleted the djurek/cargo-feed-auth branch August 12, 2026 16:46
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.

2 participants