Skip to content

🐛 v2.5.8 Biome panics on invalid CSS in HTML style attributes #11315

Description

@D3Pheonix

Environment information

Details
CLI:
  Version:                      2.5.8
  Color support:                false

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_DISTRIBUTION:                npm
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  NO_COLOR:                     1
  TERM:                         dumb
  JS_RUNTIME_VERSION:           v24.18.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         <project>/biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true
  HTML full support enabled:    unset

Workspace:
  Open Documents:               0

What happened?

This is a regression in Biome 2.5.8.

Running biome check on an HTML file that contains invalid inline CSS in a style attribute causes an internal panic instead of a parser diagnostic.

The issue was initially discovered in <svg> elements, but it is not SVG-specific: an ordinary HTML <div> reproduces the same panic.

Playground reproduction (open the Console pane): https://biomejs.dev/playground/?tab=formatter&pane=Console&files.main.html=PABkAGkAdgAgAHMAdAB5AGwAZQA9ACIAOQBmAGkAbABsAC0AbwBwAGEAYwBpAHQAeQA6ADEAOwAiAD4APAAvAGQAaQB2AD4A&files.main.tsx=

Minimal input:

<div style="9fill-opacity:1;"></div>

Steps to reproduce:

  1. Save the snippet as repro.html.
  2. Run npx @biomejs/biome check repro.html.
  3. Biome panics with:
Source Location: crates/biome_rowan/src/ast/mod.rs:207:13
Message: Tried to cast node with kind CSS_BOGUS as `"biome_css_syntax::generated::nodes::AnyCssRoot"` but was unable to cast

A second invalid inline CSS declaration produces the same panic:

<div style="color(display-p3 0.4549 0.8745 0.5451);fill-opacity:1;"></div>

The HTML is valid, but the CSS declarations embedded in the style attributes are invalid. In the Playground, the Console contains the same panic while the Diagnostics pane reports No diagnostics present and the Biome output is empty.

Expected result

Biome should report a normal diagnostic for invalid CSS embedded in an HTML style attribute and must not panic. Processing should continue for other files.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-ParserArea: parserL-CSSLanguage: CSS and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions