Skip to content

opencode-config-normalize: the repair write discards the config's permissions (0600 -> 0644) and silently severs a symlinked config — tmp+replace with no mode copy and no symlink handling (normalize.sh:126-128) #3180

Closed

Description

@dezren39

Problem

When pkgs/opencode-config-normalize/normalize.sh does repair opencode.jsonc, its write path discards the file's existing permissions and breaks symlinks: a 0600 config comes back 0644 (umask default), and a symlinked config is replaced by a brand-new regular file at the link path while the link target keeps the unrepaired v2 keys forever.

Evidence (verified this run, main fc88d0a9, script sha256 c59dd79b…)

  • normalize.sh:126-128: the repaired text is written to a fresh sibling temp file and moved over the config —
    tmp = path.with_suffix(path.suffix + '.normalize-tmp')
    tmp.write_text(out)
    tmp.replace(path)
    Nothing copies the original file's mode onto tmp, and Path.replace on a symlinked path replaces the symlink itself, not its target. Nothing in the script checks path.is_symlink() or stat mode.
  • Laptop probe (~/git/fleet/probe-2026-10-31-laneA-normalize/, verbatim copy of the script, sha-matched to main):
    • Case B: a chmod 600 config needing repair → repaired correctly, but stat afterwards shows 644.
    • Case C: config as a symlink to target.jsonc needing repair → after the run the link path is a regular file (-rw-r--r--, no longer a symlink) holding the repaired content, while target.jsonc still contains the unrepaired "plugins" key.

Why it matters

An opencode config can carry provider credentials, so silently widening 0600 → 0644 exposes them to other local users — the same defect filed for the t3code seed write in #3170, in a second script. The symlink half is a correctness break in exactly the setups this fleet uses (dotfiles/home-manager style linked configs): the normalizer reports "repaired", the file the user actually manages through the link target is never repaired, and the link is silently severed so future target updates stop reaching the live config.

Acceptance criteria

  • After a repair, the config's permission bits equal those it had before (a 0600 fixture stays 0600); a test fixture asserts the mode, not just the content.
  • A symlinked config is repaired through the link (target content updated, symlink intact), or the script refuses with a non-zero exit and leaves both link and target byte-identical — never a silent link sever. The chosen behaviour is covered by a fixture in normalize_test.sh.
  • All existing normalize_test.sh cases still pass, including byte-identical-on-failure and idempotence.

Related

Dedup

Searched open + closed for opencode-config-normalize / normalize.sh: only #2364 (closed, agents-drop). No existing issue covers this script's write path, mode, or symlink behaviour.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/opencode-config-normalizePackage/app: opencode-config-normalize (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 31, 2026
  2. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 1, 2026
  4. 20 remaining items

  5. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (PR opened)

  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  7. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — fix landed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/opencode-config-normalizePackage/app: opencode-config-normalize (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions