Skip to content

Write the config file atomically - #5190

Merged
lillianberryfly merged 2 commits into
masterfrom
lillian/atomic-config-writes
Sep 8, 2026
Merged

Write the config file atomically#5190
lillianberryfly merged 2 commits into
masterfrom
lillian/atomic-config-writes

Conversation

@lillianberryfly

Copy link
Copy Markdown
Contributor

The config file was written with os.WriteFile, which truncates before it writes. When the write then failed, for example on a full disk, the file was left empty, and an empty config reads back as a logged-out flyctl, so every token refresh on a full disk logged the user out.

Write to a temporary file beside the config, sync it, and rename it into place, so a failed write leaves the previous contents untouched.

Claude-Session: https://claude.ai/code/session_01DMttEkUAVhL7YZFRFjhHwB

lillianberryfly and others added 2 commits September 8, 2026 16:25
The config file was written with os.WriteFile, which truncates before it
writes. When the write then failed, for example on a full disk, the file
was left empty, and an empty config reads back as a logged-out flyctl,
so every token refresh on a full disk logged the user out.

Write to a temporary file beside the config, sync it, and rename it into
place, so a failed write leaves the previous contents untouched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DMttEkUAVhL7YZFRFjhHwB
Go reports every file as 0666 on Windows, and a read-only directory
there does not block creating files inside it, so the permission check
and the simulated write failure only hold on Unix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DMttEkUAVhL7YZFRFjhHwB
@lillianberryfly
lillianberryfly merged commit 8a5607e into master Sep 8, 2026
23 of 24 checks passed
@lillianberryfly
lillianberryfly deleted the lillian/atomic-config-writes branch September 8, 2026 16:59
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