{"record":{"id":"e959a0b6c46a2391","repo":"stablyai/orca","slug":"artifact-create-recovery-record-could-not-be-read","errorCode":null,"errorMessage":"Artifact create recovery record could not be read safely.","messagePattern":"Artifact create recovery record could not be read safely\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/artifacts/artifact-create-intent-store.ts","lineNumber":143,"sourceCode":"function isScope(value: unknown): value is ArtifactShareScope {\n  if (!value || typeof value !== 'object') {\n    return false\n  }\n  const scope = value as Partial<ArtifactShareScope>\n  return [\n    scope.cloudUserId,\n    scope.cloudProfileId,\n    scope.cloudOrganizationId,\n    scope.apiOrigin\n  ].every((field) => typeof field === 'string')\n}\n\nfunction readIntent(path: string): ArtifactCreateIntent {\n  let size: number\n  try {\n    size = statSync(path).size\n  } catch (error) {\n    throw new Error('Artifact create recovery record could not be read safely.', { cause: error })\n  }\n  if (size > MAX_ARTIFACT_CREATE_INTENT_BYTES) {\n    throw new Error('Artifact create recovery record exceeds the supported size.')\n  }\n  let parsed: unknown\n  try {\n    parsed = JSON.parse(readFileSync(path, 'utf8'))\n  } catch (error) {\n    throw new Error('Artifact create recovery record could not be read safely.', { cause: error })\n  }\n  if (!parsed || typeof parsed !== 'object') {\n    throw new Error('Artifact create recovery record has an unsupported format.')\n  }\n  const intent = parsed as Partial<ArtifactCreateIntent>\n  if (\n    intent.version !== 1 ||\n    typeof intent.sourceKey !== 'string' ||\n    typeof intent.idempotencyKey !== 'string' ||","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/artifacts/artifact-create-intent-store.ts#L125-L161","documentation":"Thrown by readIntent() in artifact-create-intent-store when statSync(intentPath) fails. The recovery record file is unreadable at the filesystem level (missing, permission denied, locked). The original error is attached via `{ cause: error }` for diagnosis. This is distinct from a parse failure (746) and from an oversize file (745).","triggerScenarios":"The intent JSON file was deleted between existsSync and statSync; the file is on a network/remote userData path that became unavailable; filesystem permissions changed; another process holds an exclusive lock on Windows.","commonSituations":"Antivirus or backup software locks/removes the recovery file; userDataPath lives on a disconnected external drive; a concurrent process removed the intent during recovery; permission reset after an OS migration.","solutions":["Inspect error.cause for the exact errno (ENOENT, EACCES, EBUSY) to direct the fix.","If ENOENT, treat the missing intent as 'no pending create' and surface a user-facing recovery prompt rather than crashing.","Restore filesystem access to userDataPath / the intents directory (remount drive, fix perms, close the locking process) and retry recovery."],"exampleFix":"// before\nconst intent = readIntent(path) // statSync throws\n\n// after\ntry {\n  const intent = readIntent(path)\n} catch (e) {\n  if (e.cause?.code === 'ENOENT') return null // nothing to recover\n  throw e\n}","handlingStrategy":"try-catch","validationCode":"import { existsSync, statSync } from 'node:fs'\n\nfunction canStatIntent(path: string): boolean {\n  try { statSync(path); return true } catch { return false }\n}\n\nif (!existsSync(path) || !canStatIntent(path)) {\n  return null // treat as no pending create\n}","typeGuard":"function isNodeFsError(e: unknown): e is NodeJS.ErrnoException {\n  return e instanceof Error && typeof (e as NodeJS.ErrnoException).code === 'string'\n}","tryCatchPattern":"try {\n  const intent = getArtifactCreateIntent(profileId, userDataPath, sourceKey, scope)\n} catch (e) {\n  const cause = (e as Error).cause\n  if (cause instanceof Error && ['ENOENT','EACCES','EBUSY'].includes((cause as NodeJS.ErrnoException).code ?? '')) {\n    // file gone/locked — nothing to recover; surface user prompt\n    return null\n  }\n  throw e\n}","preventionTips":["Run recovery on a stable userDataPath (local disk, not a flaky network mount).","Close/flush processes that may lock the intents directory (antivirus, backup) during recovery.","Treat ENOENT during recovery as 'no pending create' rather than a hard failure."],"tags":["artifacts","recovery","filesystem","intent-store"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}