{"record":{"id":"3d35794b1e54350b","repo":"paperclipai/paperclip","slug":"expected-plan-plan-migrator-pack-publish-publish-image-or","errorCode":null,"errorMessage":"Expected plan, plan-migrator, pack, publish, publish-image, or result.","messagePattern":"Expected plan, plan-migrator, pack, publish, publish-image, or result\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/preview-artifacts.mjs","lineNumber":220,"sourceCode":"    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":202,"sourceCodeEnd":223,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/scripts/preview-artifacts.mjs#L202-L223","documentation":"The preview-artifacts CLI accepts exactly one subcommand: plan, plan-migrator, pack, publish, publish-image, or result. Any other (or missing) first argument reaches the else branch and throws this usage error; the catch handler prints it and sets exit code 1.","triggerScenarios":"Invoking `node scripts/preview-artifacts.mjs` with no subcommand, a typo'd subcommand (e.g. 'pubish', 'build'), or extra/misspelled arguments that shift parsing.","commonSituations":"Hand-running the script locally with the wrong verb; a GitHub Actions step passing the wrong command name; renaming a step in the workflow without updating the command argument.","solutions":["Pass one of the supported subcommands: plan, plan-migrator, pack, publish, publish-image, or result.","Check the workflow YAML for typos in the command argument and its argument order.","Run the script with no args or read the source header to see the usage before invoking.","Fix any shell quoting issues that could inject an empty first argument."],"exampleFix":"// before\nnode scripts/preview-artifacts.mjs deploy <sha> <requestId>\n// after\nnode scripts/preview-artifacts.mjs publish <sha> <requestId>","handlingStrategy":"validation","validationCode":"const COMMANDS = ['plan','plan-migrator','pack','publish','publish-image','result'];\nif (!COMMANDS.includes(process.argv[2])) {\n  throw new Error(`Unknown command ${process.argv[2]}; expected one of ${COMMANDS.join(', ')}`);\n}","typeGuard":"const isPreviewCommand = (c) => ['plan','plan-migrator','pack','publish','publish-image','result'].includes(c);","tryCatchPattern":"try {\n  await runPreviewCommand(command, args);\n} catch (e) {\n  if (String(e.message).startsWith('Expected plan')) {\n    console.error('Usage: preview-artifacts.mjs <plan|plan-migrator|pack|publish|publish-image|result> [args]');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Copy subcommand invocations from the workflow YAML rather than retyping them.","Validate the command argument in wrapper shell scripts before calling the script.","Keep argument order (command first) intact when editing workflow steps.","Document the subcommands in the team runbook to avoid typos."],"tags":["cli","usage","preview"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}