Skip to content

fix: bad options#9459

Merged
ematipico merged 7 commits intomainfrom
fix/incorrect-options
Mar 13, 2026
Merged

fix: bad options#9459
ematipico merged 7 commits intomainfrom
fix/incorrect-options

Conversation

@ematipico
Copy link
Member

Summary

Closes #9314

Test Plan

It's a bug we couldn't catch because we didn't have a test for it. So I know added some codegen to create it, so it fails in CI. The test was vibecoded and it works.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: 2770365

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

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs 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

@ematipico ematipico force-pushed the fix/incorrect-options branch from 48fbc58 to 67c19ce Compare March 12, 2026 13:07
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-HTML Language: HTML and super languages labels Mar 12, 2026
@github-actions
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 53133 53133 0
Passed 51913 51913 0
Failed 1178 1178 0
Panics 42 42 0
Coverage 97.70% 97.70% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 38 38 0
Passed 37 37 0
Failed 1 1 0
Panics 0 0 0
Coverage 97.37% 97.37% 0.00%

markdown/commonmark

Test result main count This PR count Difference
Total 652 652 0
Passed 652 652 0
Failed 0 0 0
Panics 0 0 0
Coverage 100.00% 100.00% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5466 5466 0
Passed 1915 1915 0
Failed 3551 3551 0
Panics 0 0 0
Coverage 35.03% 35.03% 0.00%

ts/babel

Test result main count This PR count Difference
Total 636 636 0
Passed 568 568 0
Failed 68 68 0
Panics 0 0 0
Coverage 89.31% 89.31% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18875 18875 0
Passed 13014 13014 0
Failed 5860 5860 0
Panics 1 1 0
Coverage 68.95% 68.95% 0.00%

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Walkthrough

Adds a test-only feature and generated test helper to validate that lint rule Options types match their canonical configuration types: a test-utils feature is added to crates/biome_configuration; codegen now emits linter_options_check.rs for lint rules; generated.rs exports the module under #[cfg(any(test, feature = "test-utils"))]; biome_service gains a test harness that collects TypeIds from registries and asserts they match the generated canonical types. Also fixes an import to use UseAriaPropsForRoleOptions.

Possibly related PRs

Suggested reviewers

  • dyc3
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: bad options' is vague and does not clearly convey the specific issue being addressed, using non-descriptive language that lacks meaningful detail. Consider using a more descriptive title such as 'fix: prevent panic in useAriaPropsForRole when misconfigured' to clarify the specific issue being resolved.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description references issue #9314 and explains the fix involves adding codegen and tests, which relates to the changeset of correcting rule options and adding validation tests.
Linked Issues check ✅ Passed The PR successfully addresses issue #9314 by fixing the incorrect options import in use_aria_props_for_role.rs and adding comprehensive type-checking mechanisms to prevent similar misconfigurations.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the panic in issue #9314: correcting options types, adding test infrastructure, and creating validation codegen for rule options alignment.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/incorrect-options
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can validate your CodeRabbit configuration file in your editor.

If your editor has YAML language server, you can enable auto-completion and validation by adding # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json at the top of your CodeRabbit configuration file.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 12, 2026

Merging this PR will not alter performance

✅ 64 untouched benchmarks
⏩ 152 skipped benchmarks1


Comparing fix/incorrect-options (2770365) with main (b309dde)

Open in CodSpeed

Footnotes

  1. 152 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@ematipico ematipico requested review from a team March 12, 2026 13:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_service/src/configuration.rs`:
- Around line 1256-1283: The current check only reports mismatched type IDs for
entries present in config_side; extend it to also fail when keys are missing by
comparing key sets between config_side (from config_side_rule_options_types())
and visitor.types: compute the set of (group, rule) keys from config_side and
from visitor.types, detect keys present in one but not the other, and add
descriptive messages to mismatches for "missing in config_side" and "missing in
visitor.types" (or vice versa); keep the existing mismatches.push behavior and
the final panic that joins mismatches so the harness fails when entries are
omitted as well as when types differ.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3bcc2d6c-48bf-435f-8975-4a59e53d1d32

📥 Commits

Reviewing files that changed from the base of the PR and between cf72050 and e870d48.

⛔ Files ignored due to path filters (1)
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (2)
  • crates/biome_service/src/configuration.rs
  • xtask/codegen/src/generate_configuration.rs

@ematipico ematipico force-pushed the fix/incorrect-options branch from 106d5f6 to e870d48 Compare March 12, 2026 16:31
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@xtask/codegen/src/generate_configuration.rs`:
- Around line 850-892: The generated test currently reconstructs TypeIds from
naming conventions (Case::Snake + to_capitalized) in
config_side_rule_options_types(), which can miss mismatches introduced by
biome_configuration_macros::lint_group_structs!() and push_to_analyzer_rules;
instead, change the test to derive the asserted TypeIds from the actual
generated config structs or by exercising the real config → AnalyzerRules
wiring: import the concrete generated group structs produced by
biome_configuration_macros::lint_group_structs!() (and the equivalent for
assists), construct/inspect the AnalyzerRules/path used by
push_to_analyzer_rules (or call the same helper used by configuration wiring),
and call TypeId::of::<ActualGeneratedOptionsType>() or inspect the resulting
AnalyzerRules mapping to build result.push entries so the test fails when the
config-layer imports the wrong options type rather than when only the naming
convention differs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bbc4f035-22f5-4f0e-9ae8-3977c82f6310

📥 Commits

Reviewing files that changed from the base of the PR and between e870d48 and a3243d8.

⛔ Files ignored due to path filters (1)
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
📒 Files selected for processing (1)
  • xtask/codegen/src/generate_configuration.rs

Comment on lines +850 to +892
// Generate the options type-check test file for lint rules
if kind == RuleCategory::Lint {
let mut push_statements = String::new();
for rg in &rule_group_names {
let snake_name = Case::Snake.convert(rg.rule_name);
let options_type_name = format!("{}Options", to_capitalized(rg.rule_name));
push_statements.push_str(&format!(
"result.push((\"{group}\", \"{rule}\", TypeId::of::<biome_rule_options::{module}::{options}>()));\n",
group = rg.group_name,
rule = rg.rule_name,
module = snake_name,
options = options_type_name,
));
}

let options_check = format!(
"\
#![expect(clippy::vec_init_then_push)]
use std::any::TypeId;

/// Returns a list of `(group, rule, config_side_type_id)` for every lint rule.
///
/// The `TypeId` is derived from the rule name convention:
/// `biome_rule_options::{{snake_case_name}}::{{PascalCaseName}}Options`
///
/// This is the type that the configuration layer uses when constructing
/// [`RuleOptions`](biome_analyze::options::RuleOptions). If the rule's
/// `type Options` doesn't match, the `debug_assert_eq!` inside
/// `RuleOptions::value()` will fire at runtime.
pub fn config_side_rule_options_types() -> Vec<(&'static str, &'static str, TypeId)> {{
let mut result = Vec::new();
{push_statements} result
}}
"
);

let options_check_file = push_directory.join("linter_options_check.rs");
update(
&options_check_file,
&xtask_glue::reformat(options_check)?,
mode,
)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

This guardrail checks the convention, not the path that actually panicked.

The emitted TypeId is rebuilt from Case::Snake + to_capitalized(rule_name), whilst the real config-side wiring still comes from biome_configuration_macros::lint_group_structs!() and then flows through push_to_analyzer_rules. If that generated wiring imports the wrong options type again, this helper can stay green because it never reads the concrete type used by the configuration layer. Please derive the assertion from the generated config structs themselves, or exercise the config → AnalyzerRules path directly; otherwise we’re testing the map, not the road. The same gap also exists for assists.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@xtask/codegen/src/generate_configuration.rs` around lines 850 - 892, The
generated test currently reconstructs TypeIds from naming conventions
(Case::Snake + to_capitalized) in config_side_rule_options_types(), which can
miss mismatches introduced by biome_configuration_macros::lint_group_structs!()
and push_to_analyzer_rules; instead, change the test to derive the asserted
TypeIds from the actual generated config structs or by exercising the real
config → AnalyzerRules wiring: import the concrete generated group structs
produced by biome_configuration_macros::lint_group_structs!() (and the
equivalent for assists), construct/inspect the AnalyzerRules/path used by
push_to_analyzer_rules (or call the same helper used by configuration wiring),
and call TypeId::of::<ActualGeneratedOptionsType>() or inspect the resulting
AnalyzerRules mapping to build result.push entries so the test fails when the
config-layer imports the wrong options type rather than when only the naming
convention differs.

@ematipico ematipico merged commit 171b2ee into main Mar 13, 2026
20 checks passed
@ematipico ematipico deleted the fix/incorrect-options branch March 13, 2026 08:46
@github-actions github-actions bot mentioned this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [v2.4.5] processing panicked: called Option::unwrap() on a None value

3 participants