{"record":{"id":"d36c0b5d3daa2329","repo":"stablyai/orca","slug":"artifact-create-recovery-record-exceeds-the-suppor","errorCode":null,"errorMessage":"Artifact create recovery record exceeds the supported size.","messagePattern":"Artifact create recovery record exceeds the supported size\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/artifacts/artifact-create-intent-store.ts","lineNumber":146,"sourceCode":"  }\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' ||\n    !intent.idempotencyKey ||\n    !isScope(intent.scope) ||\n    !isWriteBody(intent.body)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/artifacts/artifact-create-intent-store.ts#L128-L164","documentation":"Thrown by readIntent() when statSync reports a file size greater than MAX_ARTIFACT_CREATE_INTENT_BYTES (800KB RPC ceiling + 128KB = 928KB). A recovery record this large cannot be legitimate — intent payloads are small JSON — so it is rejected as a safety/DoS guard before reading. The same constant is enforced at write time (751).","triggerScenarios":"The intent file was truncated/concatenated with other data, a different file was written to the intent path, or external tooling appended to it. Possibly a corrupting disk write or a path collision.","commonSituations":"A log rotator or sync tool appended to the .json; two profileIds hashed to the same intent path; a partial write from a crashed process left a bloated file.","solutions":["Delete the offending intent file so the next create starts fresh (the create is not recoverable from corrupted state).","Investigate what wrote >928KB to an intent path — check for path-collision in intentPath() and for rogue writers.","Ensure no process holds an append-mode handle on the intents directory."],"exampleFix":"// before\n// recovery keeps failing on a 5MB intent file\n\n// after\n// quarantine + delete the corrupt intent, then re-share\nif (statSync(path).size > MAX_ARTIFACT_CREATE_INTENT_BYTES) {\n  await fs.promises.rename(path, `${path}.corrupt`)\n}","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs'\nimport { MAX_ARTIFACT_CREATE_INTENT_BYTES } from '...'\n\nfunction isIntentSizeSafe(path: string): boolean {\n  try { return statSync(path).size <= MAX_ARTIFACT_CREATE_INTENT_BYTES }\n  catch { return false }\n}\n\nif (!isIntentSizeSafe(path)) {\n  // quarantine corrupt oversized intent before readIntent throws\n  await fs.promises.rename(path, `${path}.corrupt`)\n}","typeGuard":"null","tryCatchPattern":"try {\n  return readIntent(path)\n} catch (e) {\n  if ((e as Error).message === 'Artifact create recovery record exceeds the supported size.') {\n    await quarantineIntentFile(path)\n    return null\n  }\n  throw e\n}","preventionTips":["Size-check intent files before parsing so corrupt/oversized ones can be quarantined cleanly.","Ensure no external process (log rotator, sync) appends to intent files.","Verify writeIntent uses atomic temp-then-rename so partial/garbled writes cannot inflate files."],"tags":["artifacts","recovery","filesystem","size-limit","corruption"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}