Skip to content

fix: improve trigger.pipeline validation with expression checks and better errors#196

Merged
jamesadevine merged 1 commit intomainfrom
fix/trigger-validation-improvements-v2
Apr 14, 2026
Merged

fix: improve trigger.pipeline validation with expression checks and better errors#196
jamesadevine merged 1 commit intomainfrom
fix/trigger-validation-improvements-v2

Conversation

@jamesadevine
Copy link
Copy Markdown
Collaborator

Closes #189, closes #188.

Changes

Testing

Added 3 new tests covering expression rejection for trigger pipeline name, project, and branch fields. All 727 unit tests pass.

…etter errors (#189, #188)

Add ADO expression rejection (${{, $(, $[) to triggers.pipeline.name,
triggers.pipeline.project, and triggers.pipeline.branches entries,
matching the existing checks on name/description fields.

Include the offending branch value in newline validation error messages
to aid debugging when multiple branches are configured.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Rust PR Review

Summary: Looks good — correct, well-tested, and security logic is sound. A few minor consistency nits worth cleaning up.

Findings

⚠️ Suggestions

  • src/compile/common.rs:191 — The single-element for (field, value) in [("triggers.pipeline.name", pipeline.name.as_str())] loop is unnecessary overhead. Since project is Option<String> and can't share the same iteration pattern, this loop will always contain exactly one element. Either inline the checks directly, or add a comment explaining why the loop pattern was chosen (e.g., in anticipation of adding more String fields). Not wrong, just oddly structured.

  • src/compile/common.rs:217-220 — The project newline error message was not updated to include the offending value, while the expression errors for the same field (project) do print Found: '{}'. Inconsistent:

    // expression error — includes value ✅
    "...Use literal values only. Found: '{}'", project
    // newline error — missing value ❌
    "...'triggers.pipeline.project' must be a single line..."

    Consider adding Found: '{}' to match the newline errors for name/description and the expression error for project.

  • src/compile/common.rs:226 vs 195 — Branch errors use {:?} (Debug/double-quoted) while name/project errors use '{}' (Display/single-quoted). Minor inconsistency — either format is fine, but a single style across all trigger field errors would be cleaner.

✅ What Looks Good

  • Validation fires at line 54 in standalone.rs, well before generate_pipeline_resources at line 79 — the sanitization gate is correctly placed.
  • The single-quote escaping in generate_pipeline_resources (replace('\'', "''")) is correct YAML escaping and ADO expression validation now prevents any $()/${{}}/$[] from reaching that codepath.
  • New tests cover all three fields (name, project, branches) with realistic injection payloads ($(System.AccessToken), $[variables['token']]). Good coverage.
  • No unsafe unwrap() added; consistent use of anyhow::bail!.

Generated by Rust PR Reviewer for issue #196 · ● 1.1M ·

@jamesadevine jamesadevine merged commit b0ae590 into main Apr 14, 2026
10 of 13 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

1 participant