{"record":{"id":"83c8d2aa8734b222","repo":"stablyai/orca","slug":"artifact-create-recovery-record-has-an-unsupported","errorCode":null,"errorMessage":"Artifact create recovery record has an unsupported format.","messagePattern":"Artifact create recovery record has an unsupported format\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/artifacts/artifact-create-intent-store.ts","lineNumber":155,"sourceCode":"\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)\n  ) {\n    throw new Error('Artifact create recovery record has an unsupported format.')\n  }\n  return intent as ArtifactCreateIntent\n}\n\nexport function getArtifactCreateIntent(\n  profileId: string,\n  userDataPath: string,","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/artifacts/artifact-create-intent-store.ts#L137-L173","documentation":"Thrown by readIntent() when the parsed JSON is falsy or not a plain object — e.g. parsed to null, a number, a string, or an array. Before any schema field is checked, the top-level shape must be an object. This is the coarsest format guard; finer field validation happens at 748.","triggerScenarios":"The intent file contains `null`, a bare primitive, an array, or an empty document. Often the result of a hand-edit, a different file format written to the path, or a downgraded writer.","commonSituations":"A user/developer opened the .json and replaced contents with `null` or `[]`; an older/newer version wrote a non-object container; a telemetry or log file collided with the intent path.","solutions":["Inspect the raw file content to confirm what non-object payload is present.","Delete/quarantine the malformed intent and re-create the share.","Add a migration/version check if a format change produced non-object payloads across versions."],"exampleFix":"// before\n// intent file contains: null\nconst intent = readIntent(path) // throws\n\n// after\n// delete the bad file and re-share to regenerate a well-formed intent","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs'\n\nfunction isIntentTopLevelObject(path: string): boolean {\n  let parsed: unknown\n  try { parsed = JSON.parse(readFileSync(path, 'utf8')) } catch { return false }\n  return Boolean(parsed) && typeof parsed === 'object' && !Array.isArray(parsed)\n}\n\nif (!isIntentTopLevelObject(path)) {\n  await quarantineIntentFile(path)\n  return null\n}","typeGuard":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v)\n}","tryCatchPattern":"try {\n  return readIntent(path)\n} catch (e) {\n  if ((e as Error).message === 'Artifact create recovery record has an unsupported format.') {\n    await quarantineIntentFile(path)\n    return null\n  }\n  throw e\n}","preventionTips":["Never replace intent file contents with null, primitives, or arrays.","If migrating the intent format, migrate file contents alongside any path changes.","Run a format validator over intent files on startup and quarantine the bad ones."],"tags":["artifacts","recovery","json","format-validation","intent-store"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}