Skip to content

fix(cli): keep an undecodable service config from being read as empty - #52413

Closed
feiiiiii5 wants to merge 1 commit into
anomalyco:devfrom
feiiiiii5:svc-config-read
Closed

feiiiiii5 wants to merge 1 commit into
anomalyco:devfrom
feiiiiii5:svc-config-read

Conversation

@feiiiiii5

@feiiiiii5 feiiiiii5 commented Oct 1, 2026 •

Copy link
Copy Markdown

Issue for this PR

Fixes #52412

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ServiceConfig.read returned {} for both a missing file and one it could not decode. Every mutating path writes back { ...read(), changed }, so a config that failed to decode was treated as empty and immediately overwritten with just the field being changed, dropping the stored password, hostname, port, cors and env — exit code 0, no warning.

Only an absent file reads as empty now. A file that exists but neither decoder accepts fails with its path, so the command reports it instead of rewriting it.

This sits after the legacy-config repair that has since landed on dev: a file decodeLegacy understands is still repaired in place and returned, exactly as before. Only the silent return {} as Info at the end of that chain is replaced, so the new failure channel does not take the repair path with it.

How did you verify your code works?

Rebased onto 328f74c21 and re-run:

  • bun test test/service-config.test.ts in packages/cli — with the one-line change reverted, 1 pass / 2 fail: service set exits successfully against a torn write ({"hostname":"127.0.0.1","password":"user-secr) and the stored settings are clobbered. With the change, 3 pass / 0 fail, including that a missing config still reads as empty.
  • bun run typecheck in packages/cli: clean.
  • bun run check from the repo root (lint + workspace typecheck): 32/32 tasks.

cors.test.ts in the same package already pins that a failed set must leave the stored config alone.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@feiiiiii5
feiiiiii5 changed the base branch from dev to v2 October 1, 2026 02:07
@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:25
read() collapsed a missing file and a file it could not decode into the same
{} result. Every mutating path writes back { ...read(), changed }, so a config
that failed to decode was treated as no configuration and immediately
overwritten with only the field being changed, discarding the stored password,
hostname, cors and env with no warning and exit code 0.

Only an absent file reads as empty now; one that exists but cannot be decoded
fails with the path so the command reports it instead of rewriting it.
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service set/unset silently erases the stored config when service.json cannot be decoded

1 participant