{"record":{"id":"c32696cb0040454c","repo":"paperclipai/paperclip","slug":"preview-packages-are-still-missing","errorCode":null,"errorMessage":"Preview packages are still missing.","messagePattern":"Preview packages are still missing\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/preview-artifacts.mjs","lineNumber":217,"sourceCode":"if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {\n  const [command, ...args] = process.argv.slice(2);\n  try {\n    if (command === \"plan\" || command === \"plan-migrator\") {\n      const [sha, requestId, migrator] = args;\n      validateRequest(sha, requestId);\n      if (process.env.GITHUB_REF !== \"refs/heads/master\") throw new Error(\"Preview workflow definitions must run from master.\");\n      const { image, packages } = await planArtifacts(sha, {\n        image: command === \"plan\", migrator: command === \"plan-migrator\" || migrator === \"true\",\n      });\n      appendFileSync(process.env.GITHUB_OUTPUT, `image=${image}\\npackages=${packages}\\n`);\n    } else if (command === \"pack\") packPreview(...args);\n    else if (command === \"publish\") await publishPreview(...args);\n    else if (command === \"publish-image\") await publishImage(...args);\n    else if (command === \"result\") {\n      const [sha, requestId] = args;\n      validateRequest(sha, requestId);\n      if (!await imageExists(sha)) throw new Error(\"Cloud image is still missing.\");\n      if (process.env.PREVIEW_MIGRATOR === \"true\" && !(await packageExists(\"@paperclipai/shared\", sha) && await packageExists(\"@paperclipai/db\", sha))) throw new Error(\"Preview packages are still missing.\");\n      mkdirSync(\"stack-deploy-result\", { recursive: true });\n      writeFileSync(\"stack-deploy-result/result.json\", JSON.stringify({ version: 1, stage: \"build\", requestId, sha, status: \"ready\" }) + \"\\n\");\n    } else throw new Error(\"Expected plan, plan-migrator, pack, publish, publish-image, or result.\");\n  } catch (error) { console.error(error.message); process.exitCode = 1; }\n}\n","sourceCodeStart":199,"sourceCodeEnd":223,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/scripts/preview-artifacts.mjs#L199-L223","documentation":"The 'result' subcommand verifies that the preview's cloud image and (when PREVIEW_MIGRATOR=true) the @paperclipai/shared and @paperclipai/db npm packages exist before writing stack-deploy-result/result.json. When either migrator package is missing from the registry for the given SHA, it throws this error instead of declaring the build ready.","triggerScenarios":"Running `preview-artifacts.mjs result <sha> <requestId>` with PREVIEW_MIGRATOR=true in the environment while `packageExists('@paperclipai/shared', sha)` or `packageExists('@paperclipai/db', sha)` returns false — i.e. the publish step for migrator packages was skipped, failed, or has not propagated yet.","commonSituations":"Forgetting to run the plan-migrator/publish step before result; the migrator publish job failed earlier in the workflow; npm visibility lag right after publish; PREVIEW_MIGRATOR env var set incorrectly to 'true' on a run that never published packages.","solutions":["Run the migrator pack/publish steps (plan-migrator, pack, publish) for the SHA before invoking result.","Re-run the publish step after waiting for npm propagation — publishing is idempotent for existing packages.","Check the earlier publish job logs for failures covering @paperclipai/shared and @paperclipai/db.","If this preview does not need the migrator, unset/fix PREVIEW_MIGRATOR so the package check is skipped."],"exampleFix":"// before: result without migrator packages\nawait result(sha, requestId);\n// after: publish migrator packages first\nawait publishPreview(sha, requestId); // includes shared/db packages\nawait result(sha, requestId);","handlingStrategy":"validation","validationCode":"const ready = await imageExists(sha)\n  && await packageExists('@paperclipai/shared', sha)\n  && await packageExists('@paperclipai/db', sha);\nif (!ready) throw new Error('Artifacts not ready; run publish steps first.');","typeGuard":"null","tryCatchPattern":"try {\n  await result(sha, requestId);\n} catch (e) {\n  if (String(e.message).includes('Preview packages are still missing')) {\n    console.error('Run pack/publish for @paperclipai/shared and @paperclipai/db before result.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always run the full plan → pack → publish → result sequence in the workflow.","Verify PREVIEW_MIGRATOR matches whether migrator packages were actually published.","Wait for npm propagation between publish and result steps.","Check upstream publish job status before the result job runs (needs: in Actions)."],"tags":["npm","preview","ci","dependency-missing"],"backgroundTag":"resource-not-found","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}