Repository navigation
fix(@angular/cli): strip terminal escape sequences in modern yarn error parser - #34614
Merged
Merged
Conversation
…or parser Modern Yarn formats error detail fields such as `Response Code` with ANSI color sequences and OSC 8 hyperlinks before passing them to `StreamReport`, which serializes the formatted strings verbatim into its JSON line output. When colors are enabled, such as by default on GitHub Actions even over non-TTY pipes or via `FORCE_COLOR` and `.yarnrc.yml` settings, escape codes appear around both the `Response Code` label and status number. As a result, `parseYarnModernError` failed to match the HTTP status code, fell back to the generic `YN0035` code instead of `E404` for missing packages, and leaked raw control sequences into the parsed summary and detail text. Strip VT control characters from modern Yarn error messages prior to matching an anchored `Response Code` line, and ignore 2xx status codes for consistency with the Yarn Classic parser. In addition, split multi-line error payloads such as `YN0001` exception stack traces so `summary` only retains the first line while remaining lines move into `detail`, fall back to `UNKNOWN_ERROR` when `displayName` is an empty string (when `enableMessageNames` is disabled), and return `null` directly when no JSON error lines are present instead of delegating to `parseNpmLikeError` on every successful command output.
There was a problem hiding this comment.
Code Review
This pull request refactors the modern Yarn error parser to strip ANSI color codes and OSC 8 hyperlinks from error lines, improves HTTP status code extraction, and refines how error summaries and details are split. It also adds comprehensive unit tests to verify these changes. The review feedback suggests a robust fallback for the error summary to prevent it from being empty when the error data contains only whitespace.
alan-agius4
approved these changes
Nov 3, 2026
Collaborator
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.
Modern Yarn formats error detail fields such as
Response Codewith ANSI color sequences and OSC 8 hyperlinks before passing them toStreamReport, which serializes the formatted strings verbatim into its JSON line output. When colors are enabled, such as by default on GitHub Actions even over non-TTY pipes or viaFORCE_COLORand.yarnrc.ymlsettings, escape codes appear around both theResponse Codelabel and status number. As a result,parseYarnModernErrorfailed to match the HTTP status code, fell back to the genericYN0035code instead ofE404for missing packages, and leaked raw control sequences into the parsed summary and detail text.Strip VT control characters from modern Yarn error messages prior to matching an anchored
Response Codeline, and ignore 2xx status codes for consistency with the Yarn Classic parser. In addition, split multi-line error payloads such asYN0001exception stack traces sosummaryonly retains the first line while remaining lines move intodetail, fall back toUNKNOWN_ERRORwhendisplayNameis an empty string (whenenableMessageNamesis disabled), and returnnulldirectly when no JSON error lines are present instead of delegating toparseNpmLikeErroron every successful command output.