Repository navigation
Labels
A-PluginsArea: pluginsL-GritLanguage: GritQLS-Bug-confirmedStatus: report has been confirmed as a valid bug
Description
Environment information
CLI:
Version: 2.0.4
Color support: true
Platform:
CPU Architecture: x86_64
OS: linux
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
BIOME_THREADS: unset
NO_COLOR: unset
TERM: xterm-256color
JS_RUNTIME_VERSION: v22.9.0
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: npm/10.8.3
Biome Configuration:
Status: Loaded successfully
Path: biome.json
Formatter enabled: true
Linter enabled: true
Assist enabled: true
VCS enabled: true
Workspace:
Open Documents: 0
What happened?
Using a GritQL plugin with engine biome(1.0) causes Biome to crash with a Rust panic:
Source Location: .../grit-pattern-matcher-0.5.1/src/pattern/state.rs:68:43
Thread Name: tokio-runtime-worker
Message: index out of bounds: the len is 0 but the index is 0
When triggered from the language server, the LSP connection then errors with:
Header must provide a Content-Length property.
Minimal Reproduction
Files:
biome.js
{
"assist": {
"actions": {
"source": {
"organizeImports": {
"level": "on",
"options": {
"groups": [
"@app", "@app/**",
"@pages", "@pages/**",
"@widgets", "@widgets/**",
"@features", "@features/**",
"@entities", "@entities/**",
"@shared", "@shared/**",
":PACKAGE:", ":ALIAS:", ":PATH:"
]
}
}
}
}
},
"plugins": [
"./tools/biome/plugins/fsd-depth.grit",
"./tools/biome/plugins/fsd-deps.grit"
]
}
/tools/biome/plugins/fsd-depth.grit
engine biome(1.0)
language js(typescript,jsx)
sequential {
`import $what from $src` where {
$src <: r"^\"@(app|pages|widgets|features|entities|shared)\/[^\/]+\/.+\"$",
register_diagnostic(
span = $src,
message = "Only 2 level paths are allowed (e.g. @layer/name).",
severity = "error"
)
},
`import $src` where {
$src <: r"^\"@(app|pages|widgets|features|entities|shared)\/[^\/]+\/.+\"$",
register_diagnostic(
span = $src,
message = "Only 2 level paths are allowed (e.g. @layer/name).",
severity = "error"
)
}
}
./tools/biome/plugins/fsd-deps.grit
engine biome(1.0)
language js(typescript,jsx)
sequential {
`import $w from $src` where {
$filename <: r".*/pages/.*",
$src <: r"^\"@app(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "pages cannot import from higher layer @app.",
severity = "error"
)
},
`import $w from $src` where {
$filename <: r".*/widgets/.*",
$src <: r"^\"@(pages|app)(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "widgets cannot import from @pages or @app.",
severity = "error"
)
},
`import $w from $src` where {
$filename <: r".*/features/.*",
$src <: r"^\"@(widgets|pages|app)(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "features cannot import from @widgets, @pages, or @app.",
severity = "error"
)
},
`import $w from $src` where {
$filename <: r".*/entities/.*",
$src <: r"^\"@(features|widgets|pages|app)(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "entities cannot import from higher layers.",
severity = "error"
)
},
`import $w from $src` where {
$filename <: r".*/shared/.*",
$src <: r"^\"@(entities|features|widgets|pages|app)(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "shared cannot import from higher layers.",
severity = "error"
)
},
`import $src` where {
$filename <: r".*/shared/.*",
$src <: r"^\"@(entities|features|widgets|pages|app)(?:/.*)?\"$",
register_diagnostic(
span = $src,
message = "shared cannot import from higher layers (side-effect import).",
severity = "error"
)
}
}
src/pages/a.ts (content doesn’t really matter; an import helps to run the matcher)
import "@app/foo";
Steps:
- npm i -D @biomejs/biome (or use your installed Biome)
- Save the files above.
- CLI path: run npx biome check .
- LSP path: open the folder in VSCode with Biome extension enabled and let it load.
Actual Behavior:
Source Location: .../grit-pattern-matcher-0.5.1/src/pattern/state.rs:68:43
Thread Name: tokio-runtime-worker
Message: index out of bounds: the len is 0 but the index is 0
Notes / Observations
The panic disappears if I:
- Remove the fsd-deps.grit plugin, or
- Remove all references to $filename from that plugin.
- Hypothesis (not confirmed): when $filename isn’t bound in the Biome plugin runtime, the matcher or condition evaluator indexes into an empty capture set and panics (index out of bounds).
- The same .grit patterns parse correctly (no “Too many patterns” / semicolon issues) once I use sequential { ... } with comma-separated patterns.
- Crash persists even when the rule never matches the current file (i.e., it may occur during rule preparation rather than only on match).
Full logs:
2025-10-16 14:17:38.490 [info] [Error - 2:17:38 PM] Client biome: connection to server is erroring.
Header must provide a Content-Length property.
{"compile error":"ParsePatternError(...)"}
Shutting down server.
Source Location: /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/grit-pattern-matcher-0.5.1/src/pattern/state.rs:68:43
Thread Name: tokio-runtime-worker
Message: index out of bounds: the len is 0 but the index is 0
Expected result
No panic.
Either:
- $filename is available to Biome plugins and rules run; or
- A clear diagnostic “$filename unavailable” / “not supported in this context”; or
- The patterns are ignored gracefully.
Code of Conduct
- I agree to follow Biome's Code of Conduct
Reacted by Thomas Pischulski
Metadata
Metadata
Assignees
Labels
A-PluginsArea: pluginsL-GritLanguage: GritQLS-Bug-confirmedStatus: report has been confirmed as a valid bug
Activity
Update dependency @biomejs/biome to v2.5.14 (#24)
Update dependency @biomejs/biome to v2.5.14 (#45)