Conversation
🦋 Changeset detectedLatest commit: 7a371d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
39212fe to
ab3ad6a
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis change makes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/biome_service/src/file_handlers/html.rs (1)
1831-1841:⚠️ Potential issue | 🟠 MajorHandle all-whitespace tokens to avoid trivia duplication and non-idempotent rewrites.
If
valueis only whitespace, bothread_leading_triviaandread_trailing_triviacan return the full string. That means the reconstructed token can duplicate whitespace (and drift across runs), which is the same class of idempotency bug this PR is fixing.🩹 Proposed fix
fn read_trailing_trivia(value: &str) -> Cow<'_, str> { let bytes = value.as_bytes(); + let leading_count = bytes + .iter() + .take_while(|&&b| matches!(b, b' ' | b'\t' | b'\n' | b'\r')) + .count(); + + if leading_count == value.len() { + return Cow::Borrowed(""); + } + let count = bytes .iter() .rev() .take_while(|&&b| matches!(b, b' ' | b'\t' | b'\n' | b'\r')) .count(); if count > 0 { Cow::Borrowed(&value[value.len() - count..]) } else { Cow::Borrowed("") } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_service/src/file_handlers/html.rs` around lines 1831 - 1841, read_trailing_trivia currently returns the full string when the input is all whitespace, which can duplicate whitespace with read_leading_trivia; update read_trailing_trivia so that if count == value.len() (i.e., the string is all whitespace) it returns an empty trivia (e.g., Cow::Borrowed("") ) instead of the whole value, ensuring only one of read_leading_trivia/read_trailing_trivia yields the full whitespace and preventing duplicated/non-idempotent rewrites.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@crates/biome_service/src/file_handlers/html.rs`:
- Around line 1831-1841: read_trailing_trivia currently returns the full string
when the input is all whitespace, which can duplicate whitespace with
read_leading_trivia; update read_trailing_trivia so that if count == value.len()
(i.e., the string is all whitespace) it returns an empty trivia (e.g.,
Cow::Borrowed("") ) instead of the whole value, ensuring only one of
read_leading_trivia/read_trailing_trivia yields the full whitespace and
preventing duplicated/non-idempotent rewrites.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f1c6df5f-d04f-4ff7-93de-e2cb29b66c03
⛔ Files ignored due to path filters (1)
crates/biome_cli/tests/snapshots/main_cases_html/check_write_html_with_embedded_style_is_idempotent.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (4)
.changeset/wise-aliens-draw.md.claude/skills/biome-developer/SKILL.mdcrates/biome_cli/tests/cases/html.rscrates/biome_service/src/file_handlers/html.rs
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Closes #9690
I knew the bug was around the update snippet, but I wasn't able to track it down. Used the AI agent to understand where the culprit was.
In the process, I also updated the biome skill; the comments they emit are pure jargon if left unchecked.
Test Plan
Added new tests
Docs