Skip to content

Fix Atomic output publishing truncated reports when serialization fails mid-stream#26

Open
jzho987 wants to merge 1 commit into
masterfrom
fix-atomic-partial-reports
Open

Fix Atomic output publishing truncated reports when serialization fails mid-stream#26
jzho987 wants to merge 1 commit into
masterfrom
fix-atomic-partial-reports

Conversation

@jzho987

@jzho987 jzho987 commented Jul 9, 2026

Copy link
Copy Markdown

Station report JSONs sometimes arrive truncated (typically the large base64-inlined WAV reports) and get quarantined as corrupt by the shipper. Root cause: Atomic publishes its temp file in a finally, so any mid-stream failure (lazy attachment read, ENOSPC) still moves partial output into the reports directory under a valid report name — and the test still reports PASS. The temp file also lived in /tmp (cross-filesystem move = non-atomic copy, racing the shipper's 5s poll) and was never fsynced (power yank can leave an empty file after the rename).

  • Discard the temp file on failure instead of publishing it
  • Create the temp file next to the destination so publishing is a true atomic rename
  • fsync before renaming

close() keeps its name and semantics, so hardware-test-framework's AtomicWithPermissions subclass is unaffected. Regression tests included; full suite passes (511 passed, 2 xfailed).

🤖 Generated with Claude Code

…ls mid-stream

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 28994926882

Coverage increased (+1.4%) to 62.04%

Details

  • Coverage increased (+1.4%) from the base build.
  • Patch coverage: 10 of 10 lines across 1 file are fully covered (100%).
  • 246 coverage regressions across 9 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

246 previously-covered lines in 9 files lost coverage.

File Lines Losing Coverage Coverage
openhtf/output/servers/station_server.py 150 0.0%
openhtf/core/test_state.py 35 90.3%
openhtf/core/test_descriptor.py 31 84.91%
openhtf/core/test_executor.py 9 97.09%
openhtf/core/phase_descriptor.py 6 91.6%
openhtf/plugs/init.py 6 95.2%
openhtf/core/test_record.py 4 98.12%
openhtf/output/servers/pub_sub.py 3 0.0%
openhtf/init.py 2 96.83%

Coverage Stats

Coverage Status
Relevant Lines: 7471
Covered Lines: 4635
Line Coverage: 62.04%
Coverage Strength: 3.1 hits per line

💛 - Coveralls

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.

2 participants