Skip to content

stripOverrides restores base value when override key is missing from local config #49

@c10l

Description

@c10l

Bug

When a user manually adds a config section to opencode-synced.overrides.jsonc that already exists in the repo's base config, and removes it from their local config, stripOverrides restores the base value instead of removing it.

Steps to Reproduce

  1. opencode.json has a server section → pushed to repo
  2. User adds server section to opencode-synced.overrides.jsonc (wants it local-only)
  3. User removes server from opencode.json
  4. Run /sync-push → reports "No local changes to push"
  5. Repo still contains server section (should be stripped)

Root Cause

In stripOverrides() (src/sync/config.ts:239-243):

if (isPlainObject(overrideValue) && isPlainObject(currentValue)) {
  // recurse...
  continue;
}
if (baseValue === undefined) {
  delete result[key];
} else {
  result[key] = baseValue; // ← restores base when override is object but local doesn't have key
}

When overrideValue is a plain object but currentValue is undefined (key not in local config), the code falls through to the scalar branch and restores the base value instead of deleting the key.

Expected Behavior

If an override declares a key that doesn't exist in the local config, it should be stripped from the repo result regardless of whether the base config has it. The override means "this key is local-only."

Fix

Add a check for currentValue === undefined before the baseValue check:

if (currentValue === undefined || baseValue === undefined) {
  delete result[key];
} else {
  result[key] = baseValue;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions