Skip to content

fix(@angular/build): attach location to Sass errors and guard stack parsing - #34423

Open
alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/sass-error-locations
Open

alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/sass-error-locations

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Summary

  • Populate structured esbuild location on Sass Exception errors via a shared spanToLocation helper (matching Sass warnings) so BundlerContext.#addErrorsToWatch can track failed .scss files even when #loadCache is disabled.
  • Add a bounds check (index < segments.length) in extractFilesFromStack and skip stack trace lines without a line:col segment to prevent TypeError: Cannot read properties of undefined (reading 'match').

…arsing

Populate the structured esbuild `location` on Sass `Exception` errors using
a shared `spanToLocation` helper (matching Sass warnings) so that failed
stylesheet files are tracked on error messages. Also add a bounds check on
`index < segments.length` in `extractFilesFromStack` to avoid throwing a
`TypeError` when a stack trace line does not contain a `line:col` segment.
@alan-agius4
alan-agius4 requested a review from dgp1130 October 20, 2026 09:21
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 20, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 09:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors Sass error handling in the Angular build tool by extracting location mapping into a helper function and populating structured location details for compilation errors. It also adds bounds checks when parsing Sass stack traces and introduces comprehensive unit tests. Feedback on these changes highlights a bug where file paths containing spaces are incorrectly reconstructed without spaces, and suggests ensuring that the file path resolves to undefined instead of null to match esbuild's expected types.

Comment thread packages/angular/build/src/tools/esbuild/stylesheets/sass-language.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant