stablyai/orca · error

[verify-packaged-plugin-resources] invalid ${label} at ${pat

Error message

[verify-packaged-plugin-resources] invalid ${label} at ${path}: ${error instanceof Error ? error.message : String(error)}

What it means

Thrown by the readJsonFile helper in the packaged plugin resource verifier when JSON.parse fails on a file that is expected to be valid JSON. The function wraps readFileSync + JSON.parse in a try-catch and re-throws with context about which file (label) and path failed. The label identifies whether it was the 'bundled plugin index', 'marketplace index', or 'plugin manifest'. The original parse error message is included.

Source

Thrown at config/scripts/verify-packaged-plugin-resources.cjs:64

    }
  }
  visit(root)
  const hash = createHash('sha256').update('orca-plugin-tree-v1\0')
  for (const file of files) {
    const relativePath = relative(root, file.path).replaceAll('\\', '/')
    hashLength(hash, Buffer.byteLength(relativePath, 'utf8'))
    hash.update(relativePath, 'utf8')
    hashLength(hash, file.size)
    hash.update(readFileSync(file.path))
  }
  return hash.digest('hex')
}

function readJsonFile(path, label) {
  try {
    return JSON.parse(readFileSync(path, 'utf8'))
  } catch (error) {
    throw new Error(
      `[verify-packaged-plugin-resources] invalid ${label} at ${path}: ${error instanceof Error ? error.message : String(error)}`
    )
  }
}

function verifyPackagedPluginResources(resourcesDir) {
  const launchRoot = join(resourcesDir, 'plugins', 'launch')
  if (!statSync(launchRoot).isDirectory()) {
    throw new Error(`[verify-packaged-plugin-resources] missing launch directory at ${launchRoot}`)
  }
  const index = readJsonFile(join(launchRoot, 'bundled-plugins.json'), 'bundled plugin index')
  readJsonFile(join(launchRoot, 'orca-marketplace.json'), 'marketplace index')
  if (index?.version !== 1 || !Array.isArray(index.plugins) || index.plugins.length === 0) {
    throw new Error('[verify-packaged-plugin-resources] bundled plugin index is empty or invalid')
  }
  const resolvedRoot = resolve(launchRoot)
  for (const entry of index.plugins) {
    if (

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Read the error message to identify which file (label) and path failed, then validate the JSON: node -e "JSON.parse(require('fs').readFileSync('<path>','utf8')); console.log('valid')".
  2. Fix the JSON syntax error in the identified file.
  3. If the file is empty or missing, re-run the generation step that produces it (the plugin bundling/indexing pipeline).
  4. If the JSON is valid but the readFileSync error is ENOENT, verify the packaging step actually emitted the file to the expected location.
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate JSON files before the verification script runs.
const { readFileSync, existsSync } = require('node:fs')

function preValidateJson(path, label) {
  if (!existsSync(path)) {
    return { ok: false, message: `${label} not found at ${path}` }
  }
  try {
    JSON.parse(readFileSync(path, 'utf8'))
    return { ok: true }
  } catch (error) {
    return { ok: false, message: `${label} has invalid JSON at ${path}: ${error.message}` }
  }
}

Type guard

// Narrow that a parsed value is a valid plugin manifest shape.
function isValidPluginManifest(value) {
  return (
    typeof value === 'object' &&
    value !== null &&
    typeof value.publisher === 'string' &&
    typeof value.id === 'string'
  )
}

Try / catch

// readJsonFile already wraps the error with context.
// External callers should catch and inspect the label in the message.
try {
  verifyPackagedPluginResources(resourcesDir)
} catch (error) {
  if (error.message.includes('invalid') && error.message.includes('at ')) {
    // Extract the file path from the error for targeted fix
    const pathMatch = error.message.match(/at (.+?):/)
    console.error('JSON validation failed for:', pathMatch ? pathMatch[1] : 'unknown path')
  }
  throw error
}

Prevention

When it happens

Trigger: readJsonFile is called for bundled-plugins.json, orca-marketplace.json, or orca-plugin.json, and the file either doesn't exist (readFileSync throws ENOENT), exists but contains invalid JSON syntax, or is empty. The catch block normalizes the error to include the label and path.

Common situations: A plugin manifest (orca-plugin.json) was hand-edited with a syntax error (trailing comma, unquoted key); the bundled-plugins.json was generated by a script that produced malformed output; the file was truncated during a failed write (partial write due to disk full or process kill); the file is empty because the generation step produced no output.

Related errors


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