stablyai/orca · error

Artifact create recovery record could not be read safely.

Error message

Artifact create recovery record could not be read safely.

What it means

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

Source

Thrown at src/main/artifacts/artifact-create-intent-store.ts:143

function isScope(value: unknown): value is ArtifactShareScope {
  if (!value || typeof value !== 'object') {
    return false
  }
  const scope = value as Partial<ArtifactShareScope>
  return [
    scope.cloudUserId,
    scope.cloudProfileId,
    scope.cloudOrganizationId,
    scope.apiOrigin
  ].every((field) => typeof field === 'string')
}

function readIntent(path: string): ArtifactCreateIntent {
  let size: number
  try {
    size = statSync(path).size
  } catch (error) {
    throw new Error('Artifact create recovery record could not be read safely.', { cause: error })
  }
  if (size > MAX_ARTIFACT_CREATE_INTENT_BYTES) {
    throw new Error('Artifact create recovery record exceeds the supported size.')
  }
  let parsed: unknown
  try {
    parsed = JSON.parse(readFileSync(path, 'utf8'))
  } catch (error) {
    throw new Error('Artifact create recovery record could not be read safely.', { cause: error })
  }
  if (!parsed || typeof parsed !== 'object') {
    throw new Error('Artifact create recovery record has an unsupported format.')
  }
  const intent = parsed as Partial<ArtifactCreateIntent>
  if (
    intent.version !== 1 ||
    typeof intent.sourceKey !== 'string' ||
    typeof intent.idempotencyKey !== 'string' ||

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Inspect error.cause for the exact errno (ENOENT, EACCES, EBUSY) to direct the fix.
  2. If ENOENT, treat the missing intent as 'no pending create' and surface a user-facing recovery prompt rather than crashing.
  3. Restore filesystem access to userDataPath / the intents directory (remount drive, fix perms, close the locking process) and retry recovery.

Example fix

// before
const intent = readIntent(path) // statSync throws

// after
try {
  const intent = readIntent(path)
} catch (e) {
  if (e.cause?.code === 'ENOENT') return null // nothing to recover
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

import { existsSync, statSync } from 'node:fs'

function canStatIntent(path: string): boolean {
  try { statSync(path); return true } catch { return false }
}

if (!existsSync(path) || !canStatIntent(path)) {
  return null // treat as no pending create
}

Type guard

function isNodeFsError(e: unknown): e is NodeJS.ErrnoException {
  return e instanceof Error && typeof (e as NodeJS.ErrnoException).code === 'string'
}

Try / catch

try {
  const intent = getArtifactCreateIntent(profileId, userDataPath, sourceKey, scope)
} catch (e) {
  const cause = (e as Error).cause
  if (cause instanceof Error && ['ENOENT','EACCES','EBUSY'].includes((cause as NodeJS.ErrnoException).code ?? '')) {
    // file gone/locked — nothing to recover; surface user prompt
    return null
  }
  throw e
}

Prevention

When it happens

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

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

Related errors


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