-
-
Notifications
You must be signed in to change notification settings - Fork 721
fix(language_server): fix panic when "disable rule for this line" position is after error span #14597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
c2d0c6e to
bdb18c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a panic in the language server that occurs when trying to add "disable rule for this line" actions when the error position is after the error span. The fix prevents generating ignore fixes for edge cases where the error offset equals the section offset with zero span length, and adds a safety check to prevent slice index panics.
- Adds early return logic to prevent generating ignore fixes when error is at section boundary with zero span
- Implements bounds checking in
disable_for_this_lineto prevent slice index panics - Includes comprehensive test coverage for the edge case scenario
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_language_server/src/linter/error_with_position.rs | Core fix with early return logic and bounds checking |
| crates/oxc_language_server/src/linter/server_linter.rs | Integration test for the specific issue |
| crates/oxc_language_server/fixtures/linter/issue_14565/foo-bar.astro | Test fixture file triggering the issue |
| crates/oxc_language_server/fixtures/linter/issue_14565/.oxlintrc.json | Configuration for test case |
| crates/oxc_language_server/src/snapshots/fixtures_linter_issue_14565@foo-bar.astro.snap | Expected test output snapshot |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
bdb18c3 to
2281506
Compare
Merge activity
|
…ition is after error span (#14597) The problem is, that `get_section_insert_position` get the offset after the line break. But the error offset is before the insert offset. So it gets a range of `[4..3]`. This rule makes no sense to ignore, because the span will always be 0 with a length of 0. Ignored the case for adding "ignore fixes" and fixed the panic to make sure, it will not happen for other rules. closes #14565
2281506 to
e560cc1
Compare

The problem is, that
get_section_insert_positionget the offset after the line break.But the error offset is before the insert offset. So it gets a range of
[4..3].This rule makes no sense to ignore, because the span will always be 0 with a length of 0.
Ignored the case for adding "ignore fixes" and fixed the panic to make sure, it will not happen for other rules.
closes #14565