Conversation
Writing back to a linked file merges into the file on disk, but the merge was best-effort: when the read failed the write fell through to the document regenerated from the item's fields, which deletes every comment, blank line and untracked variable in it. A .env holding one non-UTF-8 byte reads as unreadable and writes fine, so that path was reachable. - Refuse the write for a parsed link when the current contents cannot be read, and say why. - Use the merged text as the write precondition instead of the last synced digest, so a change landing between the read and the rename is refused rather than overwritten. Only an explicit overwrite of a file that could not be read at all stays unguarded. - Refuse to push over a file that moved since the last sync explicitly, rather than relying on the digest comparison inside the write. - Skip the write entirely when the merge changes nothing. - Keep a line the item does not change byte-identical, and put a changed value back in the quoting the file used when that is still safe for it. Every tracked assignment used to be rebuilt double-quoted, so one Write turned into a diff on every line of somebody's file. - Report a successful write as in sync by comparing the vault against the vault; it was measured against the file digest, which a merged file never matches.
This was referenced Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Writing an item back to its linked
.envis supposed to update the values it tracks and leave the rest of the file alone. The merge was best-effort: if reading the current contents failed, the write fell through toenvContents— the document regenerated from the item's fields — and put that on disk, deleting every comment, blank line and untracked variable in it.That path is reachable, not theoretical: a file holding a single non-UTF-8 byte fails to read as text and writes perfectly well.
Two smaller things in the same area: the write precondition was the digest from the last sync rather than the text that was actually merged, so a change arriving between the read and the rename could be silently replaced; and every tracked assignment was rebuilt double-quoted, so
LOG_LEVEL=infocame back asLOG_LEVEL="info"and one Write showed up as a diff on every line of a file somebody else maintains.What changed
Tests
PassStoreTests— new coverage for: a write refused on an unreadable file (and the file's bytes left untouched), an accepted overwrite merging into the current on-disk text and keeping a comment and a variable added there afterwards, a no-op write leaving the modification date alone, byte-identical output when no value changed, quote-style preservation, and quoting still winning for unsafe values.