{"record":{"id":"e683e1f6c7264f5d","repo":"saadeghi/daisyui","slug":"base-sha-is-required","errorCode":null,"errorMessage":"--base-sha is required","messagePattern":"--base-sha is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/pr-preview.mjs","lineNumber":573,"sourceCode":"    html: inputs.html,\n  })\n\n  return {\n    afterUrl,\n    beforeUrl,\n    components: inputs.components,\n    docsPages: inputs.docsPages,\n    headSha,\n  }\n}\n\nasync function main() {\n  const options = parsePreviewArgs(process.argv.slice(2))\n  if (options.help) {\n    console.log(usage)\n    return\n  }\n  if (!options.baseSha) throw new Error(\"--base-sha is required\")\n  if (!options.headSha) throw new Error(\"--head-sha is required\")\n  if (!options.output) throw new Error(\"--output is required\")\n\n  const preview = await generatePrPreview(options)\n  await writeFile(resolve(options.output), `${JSON.stringify(preview, null, 2)}\\n`)\n}\n\nconst isMain =\n  process.argv[1] !== undefined && import.meta.url === pathToFileURL(resolve(process.argv[1])).href\n\nif (isMain) {\n  main().catch((error) => {\n    console.error(`tailwind-play-pr-preview: ${error.message}`)\n    process.exitCode = 1\n  })\n}\n","sourceCodeStart":555,"sourceCodeEnd":590,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/pr-preview.mjs#L555-L590","documentation":"Thrown by main() in packages/tailwind-play-share/pr-preview.mjs:573 when the parsed CLI options object has a falsy baseSha. The script is a PR-preview generator that diffs component CSS between a base and head git commit, so a base commit is mandatory to compute the before/after state. parsePreviewArgs only sets options.baseSha when the `--base-sha` flag is present and followed by a non-undefined value; any other invocation leaves it undefined and this guard rejects it before any git or browser work runs.","triggerScenarios":"Running `bun packages/tailwind-play-share/pr-preview.mjs` without the `--base-sha <sha>` flag, or passing `--base-sha` as the last argument with no following token (in which case takeValue throws first with `--base-sha requires a value`). Also triggers if an empty string is somehow supplied, since the guard is truthiness-based (`if (!options.baseSha)`).","commonSituations":"CI workflow that forgot to populate the base SHA env var, a manual local invocation copied from memory without the flag, a refactor that renamed the flag, or a caller shell variable expanding to empty (e.g. `--base-sha $BASE` when BASE is unset).","solutions":["Add `--base-sha <40-char-sha>` to the command line, where the sha is the PR's merge-base or target-branch tip.","If sourcing from CI, ensure the base SHA variable is exported (e.g. `BASE_SHA=$(git rev-parse origin/main)`) before invoking the script.","Run with `--help` to confirm the exact flag name and required ordering.","If scripting the call, validate the base SHA is non-empty before invoking to get a clearer upstream error."],"exampleFix":"// before\nbun packages/tailwind-play-share/pr-preview.mjs --output preview.json\n// after\nbun packages/tailwind-play-share/pr-preview.mjs --base-sha \"$BASE_SHA\" --head-sha \"$HEAD_SHA\" --output preview.json","handlingStrategy":"validation","validationCode":"import { parsePreviewArgs } from \"./packages/tailwind-play-share/pr-preview.mjs\"\n\nconst options = parsePreviewArgs(argv)\nif (!options.baseSha) {\n  console.error(\"Missing --base-sha; pass the base commit SHA (e.g. origin/main).\")\n  process.exit(2)\n}\nif (!options.headSha) {\n  console.error(\"Missing --head-sha; pass the head commit SHA (e.g. HEAD).\")\n  process.exit(2)\n}","typeGuard":"function hasBaseSha(options) {\n  return typeof options.baseSha === \"string\" && options.baseSha.length > 0\n}","tryCatchPattern":"try {\n  // ...call main / generatePrPreview with a validated baseSha\n} catch (error) {\n  if (error.message === \"--base-sha is required\") {\n    console.error(\"Base SHA missing; set BASE_SHA and rerun.\")\n    process.exit(2)\n  }\n  throw error\n}","preventionTips":["Pin CI inputs: require base/head SHA workflow inputs with `required: true` so the job fails to start rather than failing inside the script.","Derive SHAs from git at the call site (`git rev-parse origin/main`, `git rev-parse HEAD`) so they are never empty.","Wrap the invocation in a shell function that asserts both SHAs are non-empty before forwarding to the .mjs file."],"tags":["cli","argument-validation","validation","pr-preview"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}