{"record":{"id":"d5c7e451bbaeeb22","repo":"stablyai/orca","slug":"artifact-share-records-have-an-unsupported-format","errorCode":null,"errorMessage":"Artifact share records have an unsupported format.","messagePattern":"Artifact share records have an unsupported format\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/artifacts/artifact-share-record-store.ts","lineNumber":127,"sourceCode":"  if (!existsSync(path)) {\n    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }\n  }\n  let parsed: ParsedArtifactShareRecordFile\n  try {\n    parsed = JSON.parse(readFileSync(path, 'utf8')) as ParsedArtifactShareRecordFile\n  } catch (error) {\n    throw new Error('Artifact share records could not be read safely.', { cause: error })\n  }\n  if (parsed.version === 1) {\n    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }\n  }\n  if (\n    parsed.version !== 2 ||\n    !parsed.shares ||\n    typeof parsed.shares !== 'object' ||\n    Array.isArray(parsed.shares)\n  ) {\n    throw new Error('Artifact share records have an unsupported format.')\n  }\n  const shareEntries = Object.entries(parsed.shares as Record<string, unknown>)\n  const validShares = Object.fromEntries(\n    shareEntries.filter((entry): entry is [string, ArtifactShareRecord] => isRecord(entry[1]))\n  )\n  const pruned = pruneExpired\n    ? pruneRecords(validShares, Date.now(), preserveExpired)\n    : { shares: validShares, changed: false }\n  const records: ArtifactShareRecordFile = {\n    version: 2,\n    lifecycleGeneration:\n      Number.isSafeInteger(parsed.lifecycleGeneration) && Number(parsed.lifecycleGeneration) >= 0\n        ? Number(parsed.lifecycleGeneration)\n        : 0,\n    lifecycleNonce: typeof parsed.lifecycleNonce === 'string' ? parsed.lifecycleNonce : '',\n    shares: pruned.shares\n  }\n  if (pruned.changed || shareEntries.length !== Object.keys(validShares).length) {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/artifacts/artifact-share-record-store.ts#L109-L145","documentation":"Thrown by the share-record store reader after a successful parse when the schema is wrong: parsed.version is neither 2 nor 1, or `shares` is missing, not an object, or is an array. (version 1 is silently upgraded to a fresh v2 store; any other version/shape is rejected.) This is the format guard distinct from JSON corruption (752).","triggerScenarios":"A share-record file written by an incompatible version (version 3+), a hand-edited file with the wrong top-level shape, or a downgraded reader hitting a newer-format store. Also if `shares` was replaced with an array or primitive.","commonSituations":"Version skew between Orca releases; a migration tool partially rewrote the file; manual edit changed `shares` to an array; a different file format collided with the record path.","solutions":["Check parsed.version — if it is a future version, either upgrade Orca or reset the store (existing shares will need re-sharing).","Inspect the `shares` field shape to find what malformation triggered the guard.","Back up and delete the malformed file so a clean v2 store is recreated, then re-share active artifacts."],"exampleFix":"// before\n// record file = { version: 3, shares: {...} } -> version !== 2 and !== 1 throws\n\n// after\n// back up then remove the incompatible file; reader will recreate {version:2,...}; re-share artifacts","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs'\n\nfunction isShareRecordFileShape(path: string): boolean {\n  let parsed: any\n  try { parsed = JSON.parse(readFileSync(path, 'utf8')) } catch { return false }\n  if (parsed?.version === 1) return true // silently upgraded\n  return parsed?.version === 2\n    && parsed.shares && typeof parsed.shares === 'object' && !Array.isArray(parsed.shares)\n}\n\nif (existsSync(path) && !isShareRecordFileShape(path)) {\n  await backupAndResetShareRecords(profileId, userDataPath)\n}","typeGuard":"import type { ArtifactShareRecordFile } from '...'\n\nfunction isArtifactShareRecordFile(v: unknown): v is ArtifactShareRecordFile {\n  if (typeof v !== 'object' || v === null) return false\n  const f = v as Partial<ArtifactShareRecordFile>\n  return (f.version === 1 || f.version === 2)\n    && (f.version !== 2 || (f.shares !== undefined && typeof f.shares === 'object' && !Array.isArray(f.shares)))\n}","tryCatchPattern":"try {\n  return readShareRecords(profileId, userDataPath)\n} catch (e) {\n  if ((e as Error).message === 'Artifact share records have an unsupported format.') {\n    await backupAndResetShareRecords(profileId, userDataPath)\n    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }\n  }\n  throw e\n}","preventionTips":["When bumping the share-record version, ship a one-time migration for existing files.","Never hand-edit the share-record file; if required, validate version=2 and shares=object afterward.","Add a startup integrity check that quarantines incompatible-version files."],"tags":["artifacts","share-record","schema","version","format-validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}