Skip to content

fix: small correctness nits (bulk parser err, scheduleWrite doc, dup mkdir)#432

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix/small-nits-bundle
May 2, 2026
Merged

fix: small correctness nits (bulk parser err, scheduleWrite doc, dup mkdir)#432
tomasz-tomczyk merged 1 commit intomainfrom
fix/small-nits-bundle

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

Three surgical correctness/UX fixes bundled into one PR.

  1. BulkCommentEntry.UnmarshalJSON errors on unparseable line types. Previously, garbage like {"line": true} silently produced Line=0 and surfaced later as a confusing "line must be > 0" validation error. Now returns line must be int or string, got <raw>. Null/absent line still permitted (existing behavior preserved — needed for review-level and file-level entries).

  2. Documented scheduleWrite locking precondition. The function reads/writes s.pendingWrite, s.writeTimer, and s.writeGen without locking — proves callers must hold s.mu. Added a doc-comment line so a future caller can't forget and race silently.

  3. Dropped redundant os.MkdirAll in saveCritJSON. atomicWriteFile already creates the parent directory, so the outer call was dead code.

Note: PR #2 (refactor/consolidate-atomic-write) is being worked on in parallel and may also touch saveCritJSON. If a trivial conflict appears here later, either order works.

Review

  • Code review: surgical nits, no behavior change beyond the documented error path
  • Parity audit: N/A (Go-only, no frontend)

Test plan

  • mise exec -- go build ./... — clean
  • mise exec -- gofmt -l . — clean
  • mise exec -- golangci-lint run ./... — 0 issues
  • mise exec -- go test -race -count=1 ./... — pass (3 consecutive clean runs)
  • Added TestBulkCommentEntry_UnmarshalJSON_InvalidLineType covering the new error path

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.36%. Comparing base (dbc3167) to head (79693c2).
⚠️ Report is 2 commits behind head on main.

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     
Flag Coverage Δ
e2e 33.98% <0.00%> (-0.14%) ⬇️
unit 63.62% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…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>
@tomasz-tomczyk tomasz-tomczyk force-pushed the fix/small-nits-bundle branch from 2d9a2d2 to 79693c2 Compare May 2, 2026 12:14
@tomasz-tomczyk tomasz-tomczyk merged commit 41a8795 into main May 2, 2026
6 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix/small-nits-bundle branch May 2, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant