fix(opencode-config): reject redacted placeholder in raw-text config writes

This commit is contained in:
Chris Scott committed 2026-09-29 16:46:10 -04:00
1 parent fa2d794239
commit 24e2037b73
3 files changed
+43 -4

No files matched your search

@@ -407,6 +407,20 @@ describe('opencode-config-file', () => {
await expect(readFile(sourcePath('opencode.json'), 'utf8')).resolves.toBe(raw)
})
it('rejects a redacted placeholder in raw content and writes nothing', async () => {
const raw = '{"theme":"dark"}'
await writeFile(sourcePath('opencode.json'), raw, 'utf8')
const error = await updateOpenCodeConfigFile(
`{\n // comment\n "instructions": ["keep", "${OPENCODE_CONFIG_REDACTED_VALUE}"],\n}\n`,
{ source: 'opencode.json' },
).catch((caught: unknown) => caught)
expect(error).toBeInstanceOf(OpenCodeConfigRedactedValueError)
expect((error as OpenCodeConfigRedactedValueError).paths).toEqual(['instructions.1'])
await expect(readFile(sourcePath('opencode.json'), 'utf8')).resolves.toBe(raw)
})
it('removes an override from the target source only and reveals inherited values', async () => {
const lower = JSON.stringify({ theme: 'light', model: 'a' })
await writeFile(sourcePath('opencode.json'), lower, 'utf8')