8000 fix(css_parser): don't panic on stray ')' in @layer prelude by Inf1mum · Pull Request #13070 · biomejs/biome · GitHub
[go: up one dir, main page]

Skip to content

fix(css_parser): don't panic on stray ')' in @layer prelude - #13070

Closed
Inf1mum wants to merge 1 commit into
biomejs:mainfrom
Inf1mum:fix/12991-layer-panic
Closed

Inf1mum wants to merge 1 commit into
biomejs:mainfrom
Inf1mum:fix/12991-layer-panic

Conversation

@Inf1mum
@Inf1mum Inf1mum commented Nov 10, 2026
Copy link
Copy Markdown

Summary

Fixes #12991.

The CSS parser panicked (assert_progressing in crates/biome_parser/src/lib.rs: "The parser is no longer progressing. Stuck at ')'") when a stray ) appeared in the prelude of an @layer at-rule, e.g.:

@layer)

Root cause

The outer LayerReferenceList ended only at { and ;, while the inner LayerNameList additionally terminates at ). For @layer), the inner list completed an empty CssLayerNameList element at the ) without consuming any token, so the outer ParseSeparatedList loop made no progress and tripped assert_progressing.

Fix

Add ) to LAYER_REFERENCE_LIST_END_SET in crates/biome_css_parser/src/syntax/at_rule/layer.rs so the outer prelude list terminates at the stray paren; the parser now emits a expected ';' but instead found ')' diagnostic (and bogus nodes) instead of panicking. The recovery set derives from this set, so it picks up ) as well.

The ) entry in the inner LAYER_NAME_LIST_END_SET is left untouched — it is needed for nested contexts such as @import url(...) layer(name) (see import.rs).

Test evidence

New fixture crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_layer_paren.css covering @layer), @layer a b) and @layer){}:

@layer)
@layer a b)
@layer){}

All three now produce diagnostics and a sane CST (CssBogusLayer / CssBogusRule) — see the committed snapshot. No existing snapshots changed.

cargo test -p biome_css_parser is fully green: 93 unit + 3 custom-property + 690 spec + 2 doc tests, 0 failed. cargo fmt --check clean; cargo clippy -p biome_css_parser --all-features --all-targets -- --deny warnings clean.

The outer `LayerReferenceList` ended only at `{` and `;`, while the
inner `LayerNameList` also terminates at `)`. For input like `@layer)`,
the inner list completed an empty element at the `)` without consuming
any token, so the outer separated list looped forever and tripped the
parser's `assert_progressing` panic.

Add `)` to `LAYER_REFERENCE_LIST_END_SET` (which also feeds the list's
recovery set) so the prelude terminates at the stray paren and the
parser emits a proper diagnostic instead of panicking. The inner
`LAYER_NAME_LIST_END_SET` keeps its `)` entry, which is needed for
nested contexts such as `@import ... layer(name)`.

Fixes biomejs#12991
@agentscanapp
agentscanapp Bot commented Nov 10, 2026
Copy link
Copy Markdown

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description follows our PR template
  • any related issues are linked
  • existing tests still pass

@agentscanapp
agentscanapp Bot commented Nov 10, 2026
Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Report this account →

Evidence
  • Issue comment and PR within minutes: Commented on an issue and opened a PR to the same repo within 5 minutes, in 2 repositories (the fastest took 115s)
  • Multiple forks: 5 repositories forked in a single 24-hour window

Last 2 PRs:

This is an automated analysis by AgentScan

@changeset-bot
changeset-bot Bot commented Nov 10, 2026
Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6416b4a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-android-arm64 Patch
@biomejs/cli-android-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-win32-x64 Patch
@biomejs/runtime Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/wasm-web Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR'%20in%20%40layer%20prelude%0A)

@github-actions github-actions Bot added A-Parser Area: parser L-CSS Language: CSS and super languages labels Nov 10, 2026
@coderabbitai
coderabbitai Bot commented Nov 10, 2026
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CSS parser now treats ) as an end token for layer reference lists, alongside { and ;. Three test inputs cover malformed @layer preludes. A patch changeset records the release change.

Possibly related issues
None. The matching issue is already linked to this PR.

Possibly related PRs

  • biomejs/biome#12992: This PR also addresses the @layer prelude panic, using recovery in LayerReferenceList::parse_element.

Suggested labels: A-Parser, L-CSS

Suggested reviewers: denbezrukov

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 6416b

The reported malformed inputs produce diagnostics, with no identified merge-blocking issue.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly identifies the CSS parser panic fix for a stray ')' in an @layer prelude.
Description check Passed The description explains the parser panic, the fix, and the test coverage. It relates directly to the changeset.
Linked Issues check Passed [ #12991 ] requests diagnostics and recovery, not a panic, for a stray ) in an @layer prelude. The change adds ) to LAYER_REFERENCE_LIST_END_SET, and the new fixture covers @layer), `@layer …
Out of Scope Changes check Passed The parser change, regression fixture, and patch changeset all address the @layer prelude panic in [ #12991 ]. No unrelated changes are identified.
Full details: Linked Issues check

Explanation

[ #12991 ] requests diagnostics and recovery, not a panic, for a stray ) in an @layer prelude. The change adds ) to LAYER_REFERENCE_LIST_END_SET, and the new fixture covers @layer), @layer a b), and @layer){}. The PR summary reports diagnostics and recovered CST output for these cases.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: biomejs/biome
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: bd9faae
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab31c562-0750-4708-8866-e846de4e54df
Commits

Reviewing files that changed from the base of the PR and between bd9faae and 6416b4a.

Files ignored due to path filters: 1

  • crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_layer_paren.css.snap is excluded by !**/*.snap and included by **
Files selected for processing: 3

  • .changeset/fix-layer-paren-panic.md
  • crates/biome_css_parser/src/syntax/at_rule/layer.rs
  • crates/biome_css_parser/tests/css_test_suite/error/at_rule/at_rule_layer_paren.css

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@Inf1mum
Inf1mum commented Nov 15, 2026
Copy link
Copy Markdown
Author

I am going to withdraw this one - no longer planning to move it forward here. Thanks for everything you are doing on Biome!

@Inf1mum Inf1mum closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser agentscan:automation-signals L-CSS Language: CSS and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 CSS parser panics on ')' in @layer prelude

1 participant

0