fix: small correctness nits (bulk parser err, scheduleWrite doc, dup mkdir)#432
Merged
tomasz-tomczyk merged 1 commit intomainfrom May 2, 2026
Merged
fix: small correctness nits (bulk parser err, scheduleWrite doc, dup mkdir)#432tomasz-tomczyk merged 1 commit intomainfrom
tomasz-tomczyk merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #432 +/- ##
==========================================
- Coverage 67.38% 67.36% -0.03%
==========================================
Files 30 30
Lines 9785 9786 +1
==========================================
- Hits 6594 6592 -2
- Misses 2679 2681 +2
- Partials 512 513 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…mkdir)
Three surgical correctness/UX fixes:
1. BulkCommentEntry.UnmarshalJSON now returns an explicit error when the
"line" field is present but is neither an int nor a string (e.g.
`{"line": true}`). Previously it silently produced Line=0, which
surfaced later as a confusing "line must be > 0" validation error.
Null/absent line is still permitted (existing behavior preserved).
2. Added a doc comment to scheduleWrite stating that callers must hold
s.mu. The function reads/writes s.pendingWrite, s.writeTimer, and
s.writeGen without locking — this was an undocumented precondition
that a future caller could miss and race silently.
3. Removed a redundant os.MkdirAll in saveCritJSON. atomicWriteFile
already creates the parent directory, so the outer call was dead
code.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2d9a2d2 to
79693c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three surgical correctness/UX fixes bundled into one PR.
BulkCommentEntry.UnmarshalJSONerrors on unparseablelinetypes. Previously, garbage like{"line": true}silently producedLine=0and surfaced later as a confusing "line must be > 0" validation error. Now returnsline must be int or string, got <raw>. Null/absentlinestill permitted (existing behavior preserved — needed for review-level and file-level entries).Documented
scheduleWritelocking precondition. The function reads/writess.pendingWrite,s.writeTimer, ands.writeGenwithout locking — proves callers must holds.mu. Added a doc-comment line so a future caller can't forget and race silently.Dropped redundant
os.MkdirAllinsaveCritJSON.atomicWriteFilealready creates the parent directory, so the outer call was dead code.Review
Test plan
mise exec -- go build ./...— cleanmise exec -- gofmt -l .— cleanmise exec -- golangci-lint run ./...— 0 issuesmise exec -- go test -race -count=1 ./...— pass (3 consecutive clean runs)TestBulkCommentEntry_UnmarshalJSON_InvalidLineTypecovering the new error path🤖 Generated with Claude Code