Repository navigation
AutoFix: treat CI build log text as data in the Copilot prompt - #441
Closed
Ewerton Scaboro da Silva (ewertons) wants to merge 3 commits into
Closed
Ewerton Scaboro da Silva (ewertons) wants to merge 3 commits into
Ewerton Scaboro da Silva (ewertons) wants to merge 3 commits into
Conversation
CI build log content was interpolated verbatim into the prompt passed to the Copilot CLI, so text echoed by a build could be read as part of the prompt's instructions. Log text is now normalized (ANSI/control characters removed, every line quoted with a leading '| ', truncated to a fixed size) and placed inside a per-run, unguessable delimiter, with the prompt stating that the delimited block is reference data only and that instructions inside it must be ignored. The branch name and PR URL interpolated into the prompt are validated before use.
Dan Cristoloveanu (dcristoloveanu)
approved these changes
Oct 20, 2026
Dan Cristoloveanu (dcristoloveanu)
left a comment
Member
There was a problem hiding this comment.
Approving the PR in order to squash bureaucracy. The PR does not contain any value, but it is the easiest way to shut up the IcM.
Dan Cristoloveanu (dcristoloveanu)
enabled auto-merge (squash)
October 20, 2026 22:03
Member
|
/azp run Azure-C-Build-Tools-Gate |
|
No pipelines are associated with this pull request. |
Member
|
Superseded by #472. The required Azure-C-Build-Tools-Gate check doesn't build fork PRs, so the branch was moved into Azure/c-build-tools as-is (same head commit 2db8eb6). Thanks Ewerton Scaboro da Silva (@ewertons). |
auto-merge was automatically disabled
October 20, 2026 23:10
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
update_deps/helper_scripts/autofix.ps1builds the prompt it passes to the Copilot CLI by interpolating CI build log text directly:$build_logsis raw Azure DevOps failed-task log content fetched byget-azure-build-failure-details/get-failed-build-logs. It is appended to the prompt verbatim, and the prompt is then run withcopilot -p $prompt --autopilot --allow-all --no-ask-user.A build echoes a lot of text that is not written by the person running the propagation: source snippets, test output, file names, commit messages. Because that text lands in the prompt with no delimitation, anything in a log that reads like a markdown heading, a code fence, or an instruction is indistinguishable from the tool's own instructions to the agent.
Fix
Build log text is now handled as data:
get-sanitized-log-blocknormalizes the log text before it reaches the prompt:|, so no line can close the block or start a new markdown section or code fence;$global:MAX_BUILD_LOG_CHARS(20000), so a large log cannot push the task instructions out of the prompt.BUILD-LOG-<guid>); any occurrence of that delimiter inside the log text is replaced, so the log cannot spoof its own end marker.$branch_nameand$pr_urlare validated before interpolation ($branch_nameis also placed into agit push origin ...command in the prompt). Unexpected values skip AutoFix instead of being embedded.Testing
Ran
get-sanitized-log-blockover log text containing ANSI colour codes, an OSC title-set sequence, a copy of the delimiter, markdown headings, code fences, and an instruction-shaped line. Verified the output contains no ESC or CR characters, no occurrence of the delimiter, and that every line is quoted. Verified truncation on a 60000-character input and that empty input returns an empty string. Script parses clean, line endings and tabs unchanged.