Skip to content

[sentry:7860774994] ArtifactService.list() in src/workspace-service/models/artifacts.ts read every /^[\w-]+\.json$/ file under <atcDir>/media-installations through Promise.all(... readDocume - #113

Open
Ooooze wants to merge 1 commit into
mainfrom
codex/sentry-fix/7860774994

Conversation

@Ooooze

@Ooooze Ooooze commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

ArtifactService.list() in src/workspace-service/models/artifacts.ts read every /^[\w-]+.json$/ file under /media-installations through Promise.all(... readDocument ...) with no per-record tolerance, so a single unreadable or invalid document rejected the whole listing. readDocument() returns the fallback only for ENOENT and otherwise throws 'Cannot read . The existing file has been preserved.' (src/terminal-data/store.ts:33, the last Sentry frame), which made WorkspaceService.snapshot() fail at service.ts:123, which made requireReadiness() fail (require-readiness.ts:12 apiDownloadWait(await snapshot())) and aborted api.start/api.restart/chat.start/chat.complete plus every snapshot consumer. The wrapper is a plain Error with no code, so failureReport() produced the generic 'workspace api.start: unknown' event with failure_reason unknown and no error_code. The fix makes only the listing tolerant: each name is mapped to readDocument(..., null).catch(() => null) with a comment, matching the existing rule in ChatHistory.summary() ('One damaged file must not hide every other conversation.'). readDocument(), get(), install()/resume(), persist() and cancel() are unchanged, so a damaged record is still refused and never silently replaced. The carried probe reproduced the exact frame chain on the base and now passes with the patch.

Evidence:
Sentry frames: store.ts:33 (readDocument throw) <- artifacts.ts:99 (Promise.all over readDocument) <- service.ts:157/:156 (execute) <- require-readiness.ts:12 (apiDownloadWait(await snapshot())) <- service.ts:123 (snapshot pushes downloads.artifacts.list() into setups) <- boot.ts:58 <- daemon.ts:240 <- run.ts:43.
Base artifacts.ts list() body: Promise.all(names.filter(...).map((n) => readDocument<ArtifactJob | null>(join(this.directory, n), null))) - one rejection rejects the whole snapshot with no catch.
readDocument() (src/terminal-data/store.ts) falls back only on ENOENT and otherwise wraps any failure in new Error(Cannot read ${path}. The existing file has been preserved., { cause: error }), an untyped error that yields failure_reason 'unknown' and no error_code in the event.
src/terminal-data/history.ts summary() already applies .catch(() => null) under the comment 'One damaged file must not hide every other conversation.', asserted by src/terminal-data/history.test.ts - the repository's own listing convention, now mirrored here.
Diagnosis probe on base 4d37e3d (== release sha, empty release diff) reproduced store.ts:33 -> Promise.all -> artifacts.ts:99 -> service.ts:157/156 with one { not json record, failing the assertion that artifacts.list still returns the readable record.
Post-patch check: src/workspace-service/models/artifacts-damaged-record.test.ts passes (1/1), asserting both execute('artifacts.list') and snapshot().setups contain the readable record 'kept' while damaged.json is skipped.
Only list() changed; get(), install(), resumeHeld(), persist() and cancel() still throw on a damaged record, so no damaged file is ever overwritten (readDocument preserves it on write paths).
diagnostic_policy for this release reports the cause-code observer already active; the patch deliberately adds no telemetry, severity or reporting change.

Regression tests: src/workspace-service/models/artifacts-damaged-record.test.ts

Full CI and human review are required.

Report: http://127.0.0.1:8080/tenants/707d0855-80ab-4e1f-a156-f1c4546cbf52/runs/3ee1c4e4-fa6b-4465-a239-d263d9b9c102

Sentry: https://atomic-chat.sentry.io/issues/7860774994/

This branch has not been deployed

No deployments
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.

1 participant