Add error handling to agent output ingestion for better failure diagnostics#11093
Merged
Add error handling to agent output ingestion for better failure diagnostics#11093
Conversation
…xceptions Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Debug Instructions Janitor workflow failure
Add error handling to agent output ingestion for better failure diagnostics
Jan 21, 2026
pelikhan
reviewed
Jan 21, 2026
| if (content.includes("\n") || content.includes("\r") || content.includes("\t")) { | ||
| const escaped = content.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t"); | ||
| return `"${escaped}"`; | ||
| function repairJson(jsonStr) { |
Contributor
There was a problem hiding this comment.
@copilot move json repairing to separate helper file, add tests
Contributor
Author
There was a problem hiding this comment.
Done! Moved repairJson to json_repair_helpers.cjs with 40 comprehensive tests covering:
- Basic repairs (quotes, keys, trimming)
- Control character escaping
- Embedded quote handling
- Brace/bracket balancing
- Trailing comma removal
- Real-world agent output patterns
All 40 tests pass ✅
Commit: 49353d5
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
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.
Fix: Instructions Janitor Workflow Failure (#11089)
Status: ✅ Ready for Review
Recent Changes
Addressed feedback from @pelikhan:
repairJsonfunction to separate helper filejson_repair_helpers.cjsFiles Modified:
actions/setup/js/collect_ndjson_output.cjs- ImportsrepairJsonfrom helperactions/setup/js/json_repair_helpers.cjs- NEW: JSON repair logic with documentationactions/setup/js/json_repair_helpers.test.cjs- NEW: 40 comprehensive testsTest Results:
Problem
The "Instructions Janitor" workflow (run #125 - 21224671739) failed on the "Ingest agent output" step. The workflow runs daily and had been succeeding (run #124 succeeded), indicating an intermittent failure rather than a systematic issue.
Root Cause
The
main()function inactions/setup/js/collect_ndjson_output.cjslacked comprehensive error handling. While the script properly handles validation errors (logging them as warnings), it was vulnerable to uncaught exceptions from:Solution
Error Handling: Added comprehensive error handling to
collect_ndjson_output.cjs:main()function body in a try-catch blockcore.error()to log error messages and stack tracescore.setFailed()to explicitly fail with clear, actionable messagesCode Organization: Extracted JSON repair logic to separate helper module:
json_repair_helpers.cjswith well-documentedrepairJsonfunctionBenefits
Note: This fix improves error reporting, diagnostics, and code organization. The workflow may still fail intermittently if the agent produces malformed output, but failures will now include detailed error information for debugging.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.