bug: secrets_sync appends duplicate keys in secrets.toml instead of replacing #111
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_skills#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When rotating a secret (e.g.
forge_token), editingsecrets.tomland runningsecrets_synccan leave the file with twoforge_tokenentries — one under[cfg]and a duplicate elsewhere. TOML's last-key-wins means the stale value silently wins on load (secrets source), so$env.FORGE_TOKENnever reflects the rotation andforge userkeeps returning 401 with the old, revoked token.Caught during a token rotation where the new value appeared not to apply across fresh SSH sessions until the duplicate at the bottom of the file was manually removed.
Location
tools/modules/secrets_lib.nu— the write path (secrets_set/ thesecrets_mergeappend logic around lines 97–140).Proposed fix
secrets source): warn when any key appears more than once insecrets.toml, so duplicates surface loudly rather than silently.secrets_synccould dedupe + canonicalize the file on every run, ensuring last-wins never causes silent wrong values.Impact
High-friction, low-severity. Silently makes rotation appear not to work. Easy to misdiagnose as a token/scope issue.