Skip to content

fix: wrap errors in atomicWriteFile with operation context#330

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix/atomic-write-error-context
Apr 21, 2026
Merged

fix: wrap errors in atomicWriteFile with operation context#330
tomasz-tomczyk merged 1 commit intomainfrom
fix/atomic-write-error-context

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Wrap all 6 error returns in atomicWriteFile with fmt.Errorf and %w for clear operation context
  • Clean up temp file on rename failure (previously leaked)
  • This is the primary data persistence path — callers can now distinguish which step failed

Test plan

  • go vet ./... clean
  • go test -race -count=1 ./... passes
  • Reviewed by Go expert agent — approved

🤖 Generated with Claude Code

Each error return in atomicWriteFile now includes which step failed
(create, write, sync, close, chmod, rename). Previously, a bare
"permission denied" gave no indication of which of the six sequential
operations caused the failure. Also wraps the final os.Rename and
cleans up the temp file on rename failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk force-pushed the fix/atomic-write-error-context branch from 51448c7 to 186b62a Compare April 21, 2026 21:13
@tomasz-tomczyk tomasz-tomczyk merged commit 4398f7a into main Apr 21, 2026
4 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the fix/atomic-write-error-context branch April 21, 2026 21:25
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