Skip to content

Preserve unrelated fields when writing the .neon context file - #433

Open
philip wants to merge 1 commit into
mainfrom
fix/neon-context-preserve-fields
Open

Preserve unrelated fields when writing the .neon context file#433
philip wants to merge 1 commit into
mainfrom
fix/neon-context-preserve-fields

Conversation

@philip

@philip philip commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Overview

updateContextFile wrote .neon wholesale, replacing the entire file on every write. That means a single neon link (or checkout, or set-context) would clobber the ephemeral _init state neon init stashes in the same file, along with anything a user had added by hand. This is the blocker that stops neon init from delegating to neon link for project setup.

Fix it by merging instead of overwriting:

  • The managed keys (orgId, projectId, branch, branchId) are still fully governed by the write, so re-linking without a branch still clears a stale one.
  • Every other ("foreign") key already in the file is read back and carried forward.
  • neon link --clear gets a dedicated clearContextFile that still resets the file wholesale, since "forget this directory" should drop everything.

neon project create already calls updateContextFile and now benefits from the same preservation without changes; its managed-key behavior is unchanged.

Split out of #431 so it can be reviewed on its own.

This pull request and its description were written by Isaac.

`updateContextFile` overwrote `.neon` wholesale, so a single `neon link`
would wipe the ephemeral `_init` state `neon init` stashes there (and any
field a user had added). Merge instead: the managed keys (orgId,
projectId, branch, branchId) are still fully governed by the write, but
foreign keys are read back and carried forward. `neon link --clear` gets
a dedicated `clearContextFile` that still resets the file wholesale.

Co-authored-by: Isaac
@andrelandgraf

Copy link
Copy Markdown
Collaborator

Why would someone write their own content to .neon?

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