stablyai/orca · error

Artifact share records have an unsupported format.

Error message

Artifact share records have an unsupported format.

What it means

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).

Source

Thrown at src/main/artifacts/artifact-share-record-store.ts:127

  if (!existsSync(path)) {
    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }
  }
  let parsed: ParsedArtifactShareRecordFile
  try {
    parsed = JSON.parse(readFileSync(path, 'utf8')) as ParsedArtifactShareRecordFile
  } catch (error) {
    throw new Error('Artifact share records could not be read safely.', { cause: error })
  }
  if (parsed.version === 1) {
    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }
  }
  if (
    parsed.version !== 2 ||
    !parsed.shares ||
    typeof parsed.shares !== 'object' ||
    Array.isArray(parsed.shares)
  ) {
    throw new Error('Artifact share records have an unsupported format.')
  }
  const shareEntries = Object.entries(parsed.shares as Record<string, unknown>)
  const validShares = Object.fromEntries(
    shareEntries.filter((entry): entry is [string, ArtifactShareRecord] => isRecord(entry[1]))
  )
  const pruned = pruneExpired
    ? pruneRecords(validShares, Date.now(), preserveExpired)
    : { shares: validShares, changed: false }
  const records: ArtifactShareRecordFile = {
    version: 2,
    lifecycleGeneration:
      Number.isSafeInteger(parsed.lifecycleGeneration) && Number(parsed.lifecycleGeneration) >= 0
        ? Number(parsed.lifecycleGeneration)
        : 0,
    lifecycleNonce: typeof parsed.lifecycleNonce === 'string' ? parsed.lifecycleNonce : '',
    shares: pruned.shares
  }
  if (pruned.changed || shareEntries.length !== Object.keys(validShares).length) {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Check parsed.version — if it is a future version, either upgrade Orca or reset the store (existing shares will need re-sharing).
  2. Inspect the `shares` field shape to find what malformation triggered the guard.
  3. Back up and delete the malformed file so a clean v2 store is recreated, then re-share active artifacts.

Example fix

// before
// record file = { version: 3, shares: {...} } -> version !== 2 and !== 1 throws

// after
// back up then remove the incompatible file; reader will recreate {version:2,...}; re-share artifacts
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs'

function isShareRecordFileShape(path: string): boolean {
  let parsed: any
  try { parsed = JSON.parse(readFileSync(path, 'utf8')) } catch { return false }
  if (parsed?.version === 1) return true // silently upgraded
  return parsed?.version === 2
    && parsed.shares && typeof parsed.shares === 'object' && !Array.isArray(parsed.shares)
}

if (existsSync(path) && !isShareRecordFileShape(path)) {
  await backupAndResetShareRecords(profileId, userDataPath)
}

Type guard

import type { ArtifactShareRecordFile } from '...'

function isArtifactShareRecordFile(v: unknown): v is ArtifactShareRecordFile {
  if (typeof v !== 'object' || v === null) return false
  const f = v as Partial<ArtifactShareRecordFile>
  return (f.version === 1 || f.version === 2)
    && (f.version !== 2 || (f.shares !== undefined && typeof f.shares === 'object' && !Array.isArray(f.shares)))
}

Try / catch

try {
  return readShareRecords(profileId, userDataPath)
} catch (e) {
  if ((e as Error).message === 'Artifact share records have an unsupported format.') {
    await backupAndResetShareRecords(profileId, userDataPath)
    return { version: 2, lifecycleGeneration: 0, lifecycleNonce: '', shares: {} }
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/d5c7e451bbaeeb22. Report an issue: GitHub.