You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compile): quote pipeline name in generated YAML to handle colons and quotes
Front-matter agent names like `Daily safe-output smoke: noop` produced
invalid YAML when substituted bare into the top-level `name:` line:
ADO YAML parsers (and `yaml.safe_load`) saw the second colon as a
mapping indicator and rejected the file with "Mapping values are not
allowed in this context." A sister bug affected hand-quoted
`displayName: "{{ agent_name }}"` lines in 1es-base.yml:37 and
stage-base.yml:6: an agent name containing an embedded `"` would
produce `displayName: "My "special" agent"` — invalid YAML.
Introduce a single `{{ pipeline_name }}` template marker that emits
the front-matter agent name plus the `-$(BuildID)` suffix as a YAML
double-quoted scalar with proper escaping for `\`, `"`, `\n`, `\r`,
`\t`, and ASCII control characters. The new `yaml_double_quoted`
helper does the encoding; `$(...)` ADO macros pass through untouched
because `$` has no special meaning inside a YAML double-quoted scalar.
The marker replaces:
* `{{ agent_name }}-$(BuildID)` on the top-level `name:` line in
base.yml and 1es-base.yml,
* hand-quoted `displayName: "{{ agent_name }}"` on the stage display
name line in 1es-base.yml and stage-base.yml.
The stage `displayName:` now carries the `-$(BuildID)` suffix as well.
This is a small cosmetic change — stage labels in the ADO UI read e.g.
"My agent-12345" instead of "My agent" — but it provides a clear visual
link between the stage label and the build run.
Other usages of `{{ agent_name }}` are unchanged. The marker is still
used inside src/data/threat-analysis.md (a markdown body, not parsed
as YAML), which is the only remaining safe substitution position.
Tests:
* 8 new unit tests for `yaml_double_quoted` cover plain strings, the
original colon bug, backslash / embedded-quote / control-character
escaping, ADO macro passthrough, and unicode.
* 2 new integration tests
(`test_compiled_yaml_survives_tricky_agent_name_{standalone,1es}`)
compile fixtures whose names contain both embedded `"` and `:`,
parse the output via serde_yaml, and assert the escaped forms
appear verbatim in the generated `name:` and `displayName:` lines.
* `test_compiled_yaml_structure` updated to require the new marker.
* All 26 smoke-suite lock files in tests/safe-outputs regenerated
with properly quoted names.
* docs/template-markers.md documents the new marker and tightens the
`{{ agent_name }}` warning to make clear it's only safe in
non-YAML positions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments