Skip to content

fix(opencode): preserve valid empty JSON config#36468

Open
aditya-vithaldas wants to merge 1 commit into
anomalyco:devfrom
aditya-vithaldas:schema-empty-config
Open

fix(opencode): preserve valid empty JSON config#36468
aditya-vithaldas wants to merge 1 commit into
anomalyco:devfrom
aditya-vithaldas:schema-empty-config

Conversation

@aditya-vithaldas

@aditya-vithaldas aditya-vithaldas commented Jul 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36374

Type of change

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

What does this PR do?

Avoids adding a dangling comma when $schema is inserted into an empty config object. The comma is now included only when the parsed config already has keys, so {} remains valid strict JSON after being rewritten.

How did you verify your code works?

  • bun test test/config/config.test.ts (97 passed)
  • bun typecheck from packages/opencode
  • Added a regression test that parses the rewritten file with JSON.parse

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 added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

Potential duplicate found:

This appears to be addressing the exact same issue as PR #36468. Both PRs are fixing the problem of writing invalid JSON when $schema is automatically added to an empty config object (the dangling comma issue). You should review PR #36380 to determine if it's already solving this problem, or if these represent different approaches to the same fix.

@aditya-vithaldas aditya-vithaldas marked this pull request as ready for review July 11, 2026 23:37
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Config auto-adding $schema writes invalid JSON (trailing comma) for an empty {} config

1 participant