fix: refuse to git fetch while the Docker case list cannot be read (release review)

readDockerCases() reads an unreadable or half-written docker-cases.json as [], so a fetch (which runs
repository hooks, and runs unattended on the interval) could run inside a Docker workspace. The fetch
paths now read it through a strict reader: the Fetch button answers a failed run (state 'error') and the
scheduler skips the tick, undoes its picks and logs once. The status and diff routes are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-27 02:58:37 +01:00
1 parent b89f15c12f
commit 1752d7ee2c
8 files changed
+221 -18

No files matched your search

+23
View File
@@ -28,6 +28,7 @@ import {
persistDockerCaseClaudeSessionId,
probeDockerCliVersion,
readDockerCases,
readDockerCasesOrThrow,
readDockerHosts,
resolveClaudeJsonSeedMount,
resolveDockerClaudeArtifacts,
@@ -70,6 +71,28 @@ describe('docker-hosts storage', () => {
expect(await readDockerCases(dir)).toEqual([]);
});
/**
* The git fetch paths read the list through the strict reader: the writer truncates and rewrites the file in
* place, and a list read as `[]` there would let a fetch run git inside a Docker workspace.
*/
it('has a strict reader that rejects a list it cannot parse, where the plain reader returns []', async () => {
expect(await readDockerCasesOrThrow(dir)).toEqual([]); // missing: no cases
await writeDockerCases(dir, [CASE]);
expect(await readDockerCasesOrThrow(dir)).toEqual([CASE]);
const path = join(dir, 'docker-cases.json');
for (const text of ['', '[{"name":"myproj","hostWorkspacePath":"/home/arkon/cas', '{"name":"myproj"}', 'null']) {
writeFileSync(path, text);
expect(await readDockerCases(dir)).toEqual([]);
const err = await readDockerCasesOrThrow(dir).then(
() => null,
(e: Error) => e
);
expect(err?.message).toMatch(/not a valid JSON array/);
// The parser's message quotes the file; the strict reader's never does.
expect(err?.message).not.toContain('/home/arkon/cas');
}
});
it('persists the last Claude conversation id keyed by container name', async () => {
await writeDockerCases(dir, [CASE, { ...CASE, name: 'other', container: 'custom-name' }]);
await persistDockerCaseClaudeSessionId(dir, dockerContainerName(CASE.name), 'conv-1');