Skip to content

fix: safely handle trailing commas in OpenCode config - #3

Merged
anthonystepvoy merged 2 commits into
anthonystepvoy:mainfrom
thaikolja:fix/json-trailing-comma-install
Aug 9, 2026
Merged

fix: safely handle trailing commas in OpenCode config#3
anthonystepvoy merged 2 commits into
anthonystepvoy:mainfrom
thaikolja:fix/json-trailing-comma-install

Conversation

@thaikolja

@thaikolja thaikolja commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Allows the install and uninstall scripts to read an existing opencode.json containing trailing commas.

Root cause

The scripts used strict JSON parsers. The initial fallback used a regular expression that also matched comma-like text inside quoted values, which could silently change user configuration.

Changes

  • Parse strict JSON first and only normalize after a parse failure.
  • Remove trailing commas with string- and escape-aware scanners in Node.js and PowerShell.
  • Preserve values such as "literal,}" and "literal,]" exactly.
  • Add functional install/uninstall regression tests for POSIX and Windows PowerShell.
  • Run installer tests on Ubuntu and Windows in GitHub Actions.
  • Update official GitHub actions to their Node 24-based major versions and restrict workflow permissions to read-only contents.

Verification

  • python scripts/validate-package.py
  • Bash syntax checks for install and uninstall scripts
  • POSIX functional installer test
  • PowerShell 7 functional installer test
  • Windows PowerShell 5.1 functional installer test
  • GitHub Actions run 31328829070: all three jobs passed

Original trailing-comma fix contributed by @thaikolja; safety hardening and regression coverage added by the maintainer.

@anthonystepvoy anthonystepvoy changed the title fix: handle trailing commas in config JSON during installation and uninstallation fix: safely handle trailing commas in OpenCode config Aug 9, 2026
@anthonystepvoy
anthonystepvoy merged commit f148205 into anthonystepvoy:main Aug 9, 2026
3 checks passed
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.

2 participants