Skip to content

fix(execute): don't overwrite env-derived ADO context with None CLI args#413

Merged
jamesadevine merged 2 commits into
mainfrom
fix/execute-env-overwrite
May 6, 2026
Merged

fix(execute): don't overwrite env-derived ADO context with None CLI args#413
jamesadevine merged 2 commits into
mainfrom
fix/execute-env-overwrite

Conversation

@jamesadevine
Copy link
Copy Markdown
Collaborator

Problem

build_execution_context in main.rs unconditionally overwrote ctx.ado_org_url and ctx.ado_project with the CLI argument values. When the --ado-org-url / --ado-project flags are not passed (the normal case during pipeline execution), these are None — wiping out the values that ExecutionContext::default() had correctly resolved from the ADO built-in variables SYSTEM_TEAMFOUNDATIONCOLLECTIONURI and SYSTEM_TEAMPROJECT.

This caused all safe outputs requiring an org URL to fail with:

AZURE_DEVOPS_ORG_URL not set

Fix

Only override the env-derived fields when the CLI flags are explicitly provided. When the org URL is overridden via CLI, ado_organization is also re-derived to stay consistent.

Testing

  • cargo build
  • cargo test — all 8 test suites pass ✅

build_execution_context unconditionally replaced ado_org_url and
ado_project (resolved by ExecutionContext::default() from
SYSTEM_TEAMFOUNDATIONCOLLECTIONURI / SYSTEM_TEAMPROJECT) with the CLI
argument values — which are None when the flags are omitted.  This
caused 'AZURE_DEVOPS_ORG_URL not set' errors for every safe output
that needs an org URL during pipeline execution.

Only override the env-derived values when the CLI flags are explicitly
provided, and re-derive ado_organization when the URL is overridden.

Co-authored-by: Copilot <[email protected]>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🔍 Rust PR Review

Summary: Fix is correct — looks good to merge.

Findings

✅ What Looks Good

  • Root cause correctly identified: ExecutionContext::default() already calls from_env_lookup and populates ado_org_url/ado_organization/ado_project from AZURE_DEVOPS_ORG_URL / SYSTEM_TEAMFOUNDATIONCOLLECTIONURI / SYSTEM_TEAMPROJECT. The old unconditional assignment (ctx.ado_org_url = ado_org_url) would clobber those with None whenever the CLI flags were omitted — exactly the failure mode described.
  • Org name re-derivation is consistent: The trim_end_matches('/').rsplit('/').next()... logic in the new if let Some(url) block mirrors from_env_lookup exactly, so CLI-override and env-var paths produce the same ado_organization shape.
  • Minimal, surgical change: Only main.rs is touched; no behaviour changes for code paths that don't call build_execution_context.

⚠️ Suggestion (non-blocking)

The org-name extraction logic is now duplicated between result.rs::from_env_lookup and main.rs::build_execution_context. Consider extracting a small private helper (e.g. fn org_from_url(url: &str) -> Option<String>) in result.rs and calling it from both sites — eliminates the risk of the two copies drifting if the URL format ever changes (e.g. on-prem `(server/redacted) Not a blocker for this fix.

Generated by Rust PR Reviewer for issue #413 · ● 284.1K ·

@jamesadevine
Copy link
Copy Markdown
Collaborator Author

@copilot implement suggestion:

The org-name extraction logic is now duplicated between result.rs::from_env_lookup and main.rs::build_execution_context. Consider extracting a small private helper (e.g. fn org_from_url(url: &str) -> Option) in result.rs and calling it from both sites — eliminates the risk of the two copies drifting if the URL format ever changes (e.g. on-prem `(server/redacted) Not a blocker for this fix.

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

@copilot implement suggestion:

The org-name extraction logic is now duplicated between result.rs::from_env_lookup and main.rs::build_execution_context. Consider extracting a small private helper (...

Done in d8fb969. Added pub fn org_from_url(url: &str) -> Option<String> in result.rs, re-exported it from safeoutputs/mod.rs, and both from_env_lookup and build_execution_context now call the shared helper.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • spsprodeus21.vssps.visualstudio.com
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d0f0aced92c66142 /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d0f0aced92c66142 /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_--ctstate /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_INVALID,NEW /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_-j 64-u�� 64-REDACTED-linux-gnu/lib/librustc_std_workspace_alloc-76b5fe9328c1063f.rlib f2fb4jpsj1vieylaqfttm0.0ikk7vs.rcgu.o p6fvx1geprfxzzmywfd0un.0ikk7vs.rcgu.o aye56pjza6ypqxhyq70v11.0ikk7vs.rcgu.o vesgkky76boimwi6r06lb8.0ikk7vs.rcgu.o 7zgff9pvc2eyng1mrg1ahr.0ikk7vs.rcgu.o dhcdrxgm7mksxhgp3jr2q0.0ikk7vs.rcgu.o i2s8qotw8djjtzho5qlazd.0ikk7vs.rcgu.o mje8qeory3b6x6cwzt2cr6.0ikk7vs.rcgu.o c7vgtofbbwksoiwgoy7uob.0ikk7vs.rcgu.o nukljfnz5fdatqa833m4lw.0ikk7vs.rcgu.o lagyne95p2ye0rkinhkt4f.0ikk7vs.rcgu.o crww0x0lv2clk5qefeiwec.0ikk7vs.rcgu.o ohdbbqkd5ma5jj9i833nt0.0ikk7vs.rcgu.o q6osdyvuebjthytdxpk70u.0ikk7vs.rcgu.o (dns block)
  • spsprodweu4.vssps.visualstudio.com
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d0f0aced92c66142 /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d0f0aced92c66142 /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_--ctstate /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_INVALID,NEW /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_-j 64-u�� 64-REDACTED-linux-gnu/lib/librustc_std_workspace_alloc-76b5fe9328c1063f.rlib f2fb4jpsj1vieylaqfttm0.0ikk7vs.rcgu.o p6fvx1geprfxzzmywfd0un.0ikk7vs.rcgu.o aye56pjza6ypqxhyq70v11.0ikk7vs.rcgu.o vesgkky76boimwi6r06lb8.0ikk7vs.rcgu.o 7zgff9pvc2eyng1mrg1ahr.0ikk7vs.rcgu.o dhcdrxgm7mksxhgp3jr2q0.0ikk7vs.rcgu.o i2s8qotw8djjtzho5qlazd.0ikk7vs.rcgu.o mje8qeory3b6x6cwzt2cr6.0ikk7vs.rcgu.o c7vgtofbbwksoiwgoy7uob.0ikk7vs.rcgu.o nukljfnz5fdatqa833m4lw.0ikk7vs.rcgu.o lagyne95p2ye0rkinhkt4f.0ikk7vs.rcgu.o crww0x0lv2clk5qefeiwec.0ikk7vs.rcgu.o ohdbbqkd5ma5jj9i833nt0.0ikk7vs.rcgu.o q6osdyvuebjthytdxpk70u.0ikk7vs.rcgu.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@jamesadevine jamesadevine merged commit aa8a09f into main May 6, 2026
@jamesadevine jamesadevine deleted the fix/execute-env-overwrite branch May 6, 2026 13:34
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