nodebuilder: preserve the existing config when config-update fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
Research direction
Read nodebuilder.UpdateConfig and SaveConfig, then trace the configuration file write path. Start with the focused filesystem regression tests described in the issue and run them against the production helper. Done means failed saves preserve the existing configuration, and replacement happens only after encoding, sync, and close succeed; the issue notes a patch is already prepared, so coordinate before taking it on.
Written by the indexing model from the issue text.
Description
Celestia Node version
Source checkout of main at e0ad7f0e4520057e34c0b03c2f345cfd6b065dac.
OS
macOS, Darwin 25.5.0, arm64. This report concerns the local configuration-file write path, not a running network deployment.
Install tools
Source checkout; Go 1.26.10 for the focused filesystem regression tests.
Others
No running node is required. The failure is reproduced with a controlled encoder error after a partial file write, rather than by filling a real node's disk.
Steps to reproduce it
- Start with an existing
config.tomlcontaining custom configuration values. - Inspect
nodebuilder.UpdateConfig: after loading and merging the configuration, it callsremoveConfig(cfgPath)beforeSaveConfig. - Exercise the current
SaveConfigwrite sequence with an encoder that writes a prefix and then returns an error. It opens the destination usingos.Create, which truncates the existing file before encoding succeeds. - Read the destination after the error. The previous contents have been replaced by the partial prefix. In
UpdateConfig, an error opening the replacement after the preceding removal can instead leave the path absent.
A deterministic local regression uses an encoder callback in place of cfg.Encode while retaining the existing os.Create / encode sequence. This reproduces the failed-write behavior without requiring actual disk exhaustion. The proposed fix runs the same tests against the production file-writing helper.
Expected result
If saving fails before replacement, return the error and leave the existing configuration intact. Only publish the new configuration after encoding, file synchronization, and close have succeeded. Preserve existing file permission bits and clean up temporary files on returned errors.
Actual result
UpdateConfig removes the original before attempting the replacement. Independently, SaveConfig truncates the destination before encoding and ignores the deferred close error. An unsuccessful update can therefore leave the configuration missing or incomplete.
Relevant log output
=== RUN TestSaveConfigAtomicReplacement
destination changed before replacement: "complete replacement\n"
--- FAIL: TestSaveConfigAtomicReplacement
=== RUN TestSaveConfigPreservesExistingFile/encode
destination changed after failed save: "partial replacement"
--- FAIL: TestSaveConfigPreservesExistingFile/encode
These are excerpts from the controlled regression of the previous write sequence, not logs from a production node.
Is the node "stuck"? Has it stopped syncing?
Not applicable. This was investigated using source code and local filesystem tests; no live node was involved.
Notes
I have prepared a focused patch that removes the pre-save deletion, writes to a temporary file in the destination directory, checks encoding / sync / close errors, and renames the completed file over the destination. It preserves existing permission bits and existing symlinks to regular files. New files use mode 0600.
The focused filesystem tests pass with the patch. The complete nodebuilder package tests have not run successfully because dependencies are unavailable in the offline environment.
This proposal addresses configuration persistence reliability. It does not claim power-loss durability: synchronizing the parent directory after rename is outside the current patch. Please let me know whether this approach fits the project before I open a pull request.
- Dominant language
- Go
- Stars
- 1k
- Forks
- 1.1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 55
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from celestiaorg/celestia-node
-
external needs:triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
celestiaorg/celestia-node#5448 ·
Maintainers usually reply within 1 day
-
area:node good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
celestiaorg/celestia-node#1178 ·
Maintainers usually reply within 1 day
-
api/client: New fails with a TLS core endpoint because the fibre state client dials insecurelyMay be free again A pull request for this issue was closed without being merged. Openexternal needs:triage
Difficulty 4/5 3-5 days Newbie friendliness 62/100
celestiaorg/celestia-node#5267 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
celestiaorg/celestia-node#5237 ·
Maintainers usually reply within 1 day
-
api/rpc/client: Close namespace connectionsPossibly taken @neyy91 claimed this 102 days ago. Openexternal needs:triage stale
Difficulty 3/5 1-2 days Newbie friendliness 72/100
celestiaorg/celestia-node#5188 ·
Maintainers usually reply within 1 day
All issues in celestiaorg/celestia-node
Similar issues
-
ConcatAgenticMessages loses the approval request ID of a streamed MCP tool callPossibly taken @ningsiyuan1024 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
containers/gvisor-tap-vsock#796 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsPossibly taken @huanghaoyuanhhy claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
zilliztech/milvus-backup#1418 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
projectdiscovery/nuclei#8423 ·
Maintainers usually reply within 1 day