Repository navigation
[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
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nocode, 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 jsonrecord, 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')andsnapshot().setupscontain 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/