{"record":{"id":"d6e0f5a9661bfb82","repo":"paperclipai/paperclip","slug":"acpx-provider-package-format-is-invalid","errorCode":null,"errorMessage":"ACPX provider package format is invalid","messagePattern":"ACPX provider package format is invalid","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/drivers/acpx/installation-integrity.ts","lineNumber":1684,"sourceCode":"    'const { fileURLToPath, pathToFileURL } = require(\"node:url\");',\n    \"const commandDirectory = process.argv[1];\",\n    \"const commandName = process.argv[2];\",\n    \"const dependencyAncestorCount = Number.parseInt(process.argv[3], 10);\",\n    \"const serverDependencyAncestorCount = Number.parseInt(process.argv[4], 10);\",\n    \"const serverPackageFormat = process.argv[5];\",\n    \"const dependencyAncestorFormats = JSON.parse(process.argv[6]);\",\n    \"const providerRuntimeExecutableCount = Number.parseInt(process.argv[7], 10);\",\n    `const providerRuntimeEnvironmentVariable = process.env.${VERIFIED_PROVIDER_RUNTIME_TARGET_ENV};`,\n    `delete process.env.${VERIFIED_PROVIDER_RUNTIME_TARGET_ENV};`,\n    `const snapshotHandoff = process.platform === \"darwin\" ? JSON.parse(process.env.${ACPX_PRIVATE_SNAPSHOT_ENV} || \"null\") : null;`,\n    'let privateSnapshot = null; if (snapshotHandoff) { const manifest = fs.readFileSync(snapshotHandoff.path); if (require(\"node:crypto\").createHash(\"sha256\").update(manifest).digest(\"hex\") !== snapshotHandoff.digest) throw new Error(\"ACPX snapshot manifest digest mismatch\"); privateSnapshot = JSON.parse(manifest); }',\n    `delete process.env.${ACPX_PRIVATE_SNAPSHOT_ENV};`,\n    'if (process.platform !== \"linux\" && !(process.platform === \"darwin\" && privateSnapshot && Array.isArray(privateSnapshot.roots) && privateSnapshot.roots.length === dependencyAncestorCount + 1)) throw new Error(\"ACPX provider requires verified package snapshots\");',\n    'const verifySnapshotBytes = (path, bytes) => { if (privateSnapshot && require(\"node:crypto\").createHash(\"sha256\").update(bytes).digest(\"hex\") !== privateSnapshot.digests[path]) throw new Error(\"ACPX private snapshot digest mismatch\"); };',\n    'if (privateSnapshot && providerRuntimeExecutableCount === 1) verifySnapshotBytes(privateSnapshot.executable, fs.readFileSync(privateSnapshot.executable));',\n    `if (!Number.isSafeInteger(dependencyAncestorCount) || dependencyAncestorCount < 0 || dependencyAncestorCount > ${MAX_DEPENDENCY_ANCESTORS}) throw new Error(\"ACPX provider dependency ancestry is invalid\");`,\n    'if (!Number.isSafeInteger(serverDependencyAncestorCount) || serverDependencyAncestorCount < 0 || serverDependencyAncestorCount > dependencyAncestorCount) throw new Error(\"ACPX provider package ancestry is invalid\");',\n    'if ((serverPackageFormat !== \"module\" && serverPackageFormat !== \"commonjs\") || !Array.isArray(dependencyAncestorFormats) || dependencyAncestorFormats.length !== dependencyAncestorCount || dependencyAncestorFormats.some((value) => value !== \"module\" && value !== \"commonjs\")) throw new Error(\"ACPX provider package formats are invalid\");',\n    'if (providerRuntimeExecutableCount !== 0 && providerRuntimeExecutableCount !== 1) throw new Error(\"ACPX provider runtime executable count is invalid\");',\n    `const providerRuntimeExecutableFd = ${DEPENDENCY_ANCESTOR_FD_START} + dependencyAncestorCount;`,\n    'if (providerRuntimeExecutableCount === 1) { if (providerRuntimeEnvironmentVariable !== \"CODEX_PATH\" && providerRuntimeEnvironmentVariable !== \"CLAUDE_CODE_EXECUTABLE\") throw new Error(\"ACPX provider runtime environment target is invalid\"); fs.fstatSync(providerRuntimeExecutableFd); process.env[providerRuntimeEnvironmentVariable] = privateSnapshot ? privateSnapshot.executable : \"/proc/\" + process.pid + \"/fd/\" + providerRuntimeExecutableFd; } else if (providerRuntimeEnvironmentVariable !== undefined) throw new Error(\"ACPX provider runtime environment target is unexpected\");',\n    ...(guarded\n      ? [\n          `const guardianFd = ${DEPENDENCY_ANCESTOR_FD_START} + dependencyAncestorCount + providerRuntimeExecutableCount;`,\n          'const guardian = fs.createReadStream(\"\", { fd: guardianFd, autoClose: false });',\n          `const reapCurrentProviderProcessGroup = ${reapCurrentProviderProcessGroup.toString()};`,\n          \"const killProviderProcess = process.kill.bind(process);\",\n          \"const providerProcessId = process.pid;\",\n          \"const exitProviderProcess = process.exit.bind(process);\",\n          \"let guardianLost = false;\",\n          \"const reapOnGuardianLoss = () => { if (guardianLost) return; guardianLost = true; reapCurrentProviderProcessGroup(killProviderProcess, providerProcessId, exitProviderProcess); };\",\n          'guardian.once(\"end\", reapOnGuardianLoss);',\n          'guardian.once(\"error\", reapOnGuardianLoss);',\n          \"guardian.resume();\",\n          \"fs.fstatSync(guardianFd + 1);\",\n          \"fs.fstatSync(guardianFd + 2);\",","sourceCodeStart":1666,"sourceCodeEnd":1702,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/src/drivers/acpx/installation-integrity.ts#L1666-L1702","documentation":"Child-bootstrap validation of module formats: serverPackageFormat must be exactly \"module\" or \"commonjs\", dependencyAncestorFormats must be an array whose length equals dependencyAncestorCount, and every entry must be \"module\" or \"commonjs\". This ensures the loader knows the format of every verified ancestor module; anything else would make module resolution ambiguous, so the child aborts.","triggerScenarios":"Child receives serverPackageFormat outside {module, commonjs}, a non-array dependencyAncestorFormats, an array length mismatched with dependencyAncestorCount, or an element that is neither \"module\" nor \"commonjs\".","commonSituations":"Hand-built argv with formats JSON truncated or wrongly quoted; package.json \"type\" field producing an unexpected format string; newer/older package versions whose formats array disagrees with the ancestor count; shells or wrappers mangling the JSON argv entry.","solutions":["Spawn via the library's verified spawn() so formats are serialized from the parent's verified arrays with JSON.stringify.","Check each ancestor package's declared module format (package.json type / .cjs/.mjs) resolves to module or commonjs only.","Confirm the JSON argv entry is passed as a single argument (not split by a shell wrapper).","Align package versions so the formats array is generated for the same ancestry the child is told about."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const FORMATS = [\"module\", \"commonjs\"];\nif (!FORMATS.includes(serverPackageFormat) ||\n    !Array.isArray(dependencyAncestorFormats) ||\n    dependencyAncestorFormats.length !== dependencyAncestors.length ||\n    !dependencyAncestorFormats.every((f) => FORMATS.includes(f))) {\n  throw new Error(\"module formats must resolve to module or commonjs for every ancestor\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure each ancestor package resolves to module or commonjs (check package.json type)","Pass the formats JSON as one argv entry, never through a splitting shell","Regenerate formats whenever the dependency ancestry changes"],"tags":["invalid-enum-value","argument-validation","process-spawn"],"backgroundTag":"invalid-enum-value","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}