Skip to content

fix(ado-script): read auto-injected collection URI in getWebApi#1311

Merged
jamesadevine merged 2 commits into
mainfrom
fix/ado-script-collection-uri-1307
Jul 2, 2026
Merged

fix(ado-script): read auto-injected collection URI in getWebApi#1311
jamesadevine merged 2 commits into
mainfrom
fix/ado-script-collection-uri-1307

Conversation

@jamesadevine

@jamesadevine jamesadevine commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1307. The Conclusion job could not file the pipeline_failure work item — conclusion.js failed with ADO_COLLECTION_URI env var is missing, so AW_REPORT_FAILURE_AS_WORK_ITEM silently produced nothing (the step is continueOnError: true).

Root cause

All ado-script bundles authenticate through the single getWebApi() chokepoint in scripts/ado-script/src/shared/auth.ts, which read the non-auto-injected ADO_COLLECTION_URI. The compiler emitted that renamed var for the gate and synthetic-PR steps, but build_conclusion_job only set SYSTEM_ACCESSTOKEN — so conclusion.js had no org URL. Meanwhile the Rust ado-aw execute path reads the auto-injected SYSTEM_TEAMFOUNDATIONCOLLECTIONURI, so the two code paths disagreed.

Fix

Align ado-script with the Rust path by reading ADO's auto-injected collection URI directly in getWebApi(): SYSTEM_COLLECTIONURI -> SYSTEM_TEAMFOUNDATIONCOLLECTIONURI. This removes the collection URI from the per-step injection contract entirely, so no compiler-emitted step can forget it again — and it fixes already-compiled .lock.yml files without recompilation (ADO auto-injects the var regardless of the env: block).

  • auth.ts — new precedence; drop ADO_COLLECTION_URI.
  • auth.test.ts — precedence coverage (prefers SYSTEM_COLLECTIONURI, falls back to SYSTEM_TEAMFOUNDATIONCOLLECTIONURI, errors when both missing).
  • filter_ir.rs + extensions/ado_script.rs — drop the now-redundant ADO_COLLECTION_URI exports from the gate and synthetic-PR step builders.
  • tests/gate_e2e.rs — set SYSTEM_COLLECTIONURI instead of ADO_COLLECTION_URI.
  • Docs: docs/ado-script.md, docs/filter-ir.md, site/.../ado-script.mdx.

Drive-by cleanup

scripts/ado-script/conclusion.js was tracked by accident (PR #1076 added the bundle but omitted it from scripts/ado-script/.gitignore). Every ado-script bundle is a build artifact shipped via the release ado-script.zip and downloaded to /tmp at runtime; the repo copy is never consumed. This PR untracks it and gitignores it alongside the other bundles.

Validation

  • vitest run — 441/441 pass.
  • cargo build, cargo test (2460+ across suites), cargo clippy --all-targets --all-features — all clean.

Follow-up (not in this PR)

The deeper issue is that the getWebApi auth-env contract is hand-rolled across ~10 compiler step builders (gate, synth-PR, conclusion, executor, every exec-context contributor), which is how the Conclusion step drifted. A follow-up will introduce a shared auth-env applier and a general contract for per-bundle env-var requirements between compiler-emitted steps and ado-script tasks.

jamesadevine and others added 2 commits July 2, 2026 14:25
conclusion.js could not file the pipeline_failure work item because the
Conclusion step never injected ADO_COLLECTION_URI, which the shared
getWebApi() auth helper required. ADO does not auto-inject that renamed
var, and the Conclusion step builder only set SYSTEM_ACCESSTOKEN.

Align ado-script with the Rust `ado-aw execute` path by reading ADO's
auto-injected collection URI directly: SYSTEM_COLLECTIONURI, falling back
to SYSTEM_TEAMFOUNDATIONCOLLECTIONURI. This removes the collection URI
from the per-step injection contract entirely, so no compiler-emitted
step can forget it again (fixes already-compiled locks too).

Also drop the now-redundant ADO_COLLECTION_URI exports from the gate and
synthetic-PR step builders, update gate_e2e to set SYSTEM_COLLECTIONURI,
refresh docs, and add auth.test.ts precedence coverage.

Fixes #1307

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Every ado-script bundle is a build artifact shipped via the release
ado-script.zip and downloaded to /tmp at pipeline runtime; the in-repo
copies are gitignored. conclusion.js was the sole exception — PR #1076
added the bundle but omitted it from scripts/ado-script/.gitignore, so
the built file was committed and tracked by accident. Nothing consumes
the repo copy (only the /tmp runtime path is referenced), so untrack it
and ignore it alongside the other bundles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine merged commit 4d20b0a into main Jul 2, 2026
17 checks passed
@jamesadevine jamesadevine deleted the fix/ado-script-collection-uri-1307 branch July 2, 2026 14:22
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.

conclusion.js fails to file pipeline_failure work item — ADO_COLLECTION_URI env var never injected by compiler (v0.39.0)

1 participant