GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(cli): refuse to overwrite an invalid service.json by kitlangton · Pull Request #66687 · anomalyco/opencode Conversation
|
| Case | Before | After |
|---|---|---|
Missing service.json on first run |
✅ Starts and creates password | ✅ Starts and creates password |
Legacy boolean remote in service.json |
✅ Repaired in place | ✅ Repaired in place |
Typo or syntax error in service.json on serve --service or service set / unset |
❌ Overwrites service.json and rotates password |
✅ Fails with path + issue; file untouched |
Unreadable service.json on service set / unset |
❌ Overwrites service.json |
✅ Fails with PlatformError; file untouched |
service status / service stop while service.json is invalid |
✅ Works | ✅ Still works via registrationFile |
The new regression tests in packages/cli/test/service-config.test.ts fail without this change (the server overwrites service.json with only a new password and exits 0 instead of reporting InvalidError); 452 pass, 9 skip, 0 fail across packages/cli.
👀 Read: packages/cli/src/services/service-config.ts, where read distinguishes NotFound from unreadable or invalid files and registrationFile splits state-file lookup from reading service.json. The rest is routine.
bun test --timeout 30000 test/service-config.test.ts --rerun-each 10 --randomize (in packages/cli): 30 pass, 0 failbun run test (in packages/cli): 452 pass, 9 skip, 0 failbun run check: 36/36 tasks passbun run typecheck:tsc: 34/34 tasks passAdded by the opencode bot (AI-generated).
Fixes #52412
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The fix works. I reproduced the data loss on the base branch (an invalid service.json is wiped by service set and by serve --service, which also rotates the password). With this PR, both commands stop with ServiceConfig.InvalidError naming the file and the bad field, and the file is left untouched. opencode run now shows the same clear error, and service status still works. The reproduction script from #52412 behaves the same way. The new tests pass here and fail 3 of 5 on the base, and tsc -b passes for packages/cli.
Public API: the file format and CLI commands are unchanged. An invalid service.json now causes an error instead of being treated as empty.
One request: the new test file is quite large for what it checks (see inline comment).
Fixes #52412
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
|
|
||
| yield* Effect.forEach( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This runs 24 operations against each of 3 sample files, which makes the test long and harder to read than the fix needs. One read() check that the error names the path, plus one or two commands that write (e.g. set("port", …) and password()) showing the file is untouched, would cover the fix. The unreadable-file test and the serve --service subprocess test could also be shortened to their key assertions.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The test file is now much smaller: one read() check, a few commands that write showing the file stays untouched, the unreadable-file case, and one command-line test covering serve --service and service status/stop. That covers my earlier comment. The tests pass and tsc -b passes in packages/cli. The fix itself is unchanged from what I verified before, and the public API is unchanged. No new concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
service set/unset silently erases the stored config when service.json cannot be decoded
There was an error while loading. Please reload this page.