{"record":{"id":"b278ebf066214281","repo":"saadeghi/daisyui","slug":"head-sha-is-required","errorCode":null,"errorMessage":"--head-sha is required","messagePattern":"--head-sha is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/pr-preview.mjs","lineNumber":574,"sourceCode":"  })\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":556,"sourceCodeEnd":590,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/pr-preview.mjs#L556-L590","documentation":"Thrown by main() in packages/tailwind-play-share/pr-preview.mjs:574 when the parsed CLI options object has a falsy headSha. The generator reads changed component CSS at the head commit and renders it in Tailwind Play, so a head commit identifier is required. parsePreviewArgs only sets options.headSha when the `--head-sha` flag is supplied with a value; otherwise it stays undefined and this guard fails fast before any diffing or browser launch.","triggerScenarios":"Invoking the script without the `--head-sha <sha>` flag, or with `--head-sha` as the final token (caught earlier by takeValue as `--head-sha requires a value`). An empty-string value would also trip the truthiness check.","commonSituations":"CI job missing the PR head SHA input, a local test run that only set the base sha, a GitHub Actions step where `github.event.pull_request.head.sha` was referenced in a non-Pull Request event (so it is empty), or a typo'd flag name like `--head_sha` or `--head`.","solutions":["Add `--head-sha <40-char-sha>` (the PR's latest commit) to the command line.","In GitHub Actions, gate the step on `github.event_name == 'pull_request'` and use `github.event.pull_request.head.sha`.","If invoking locally, export HEAD_SHA from `git rev-parse HEAD` and pass `--head-sha \"$HEAD_SHA\"`.","Run with `--help` to verify flag spelling and argument order."],"exampleFix":"// before\nbun packages/tailwind-play-share/pr-preview.mjs --base-sha \"$BASE_SHA\" --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.headSha) {\n  console.error(\"Missing --head-sha; pass the head commit SHA (e.g. HEAD).\")\n  process.exit(2)\n}","typeGuard":"function hasHeadSha(options) {\n  return typeof options.headSha === \"string\" && options.headSha.length > 0\n}","tryCatchPattern":"try {\n  // ...call main / generatePrPreview with a validated headSha\n} catch (error) {\n  if (error.message === \"--head-sha is required\") {\n    console.error(\"Head SHA missing; pass --head-sha with the PR commit.\")\n    process.exit(2)\n  }\n  throw error\n}","preventionTips":["In GitHub Actions, gate the step on pull_request events and read `github.event.pull_request.head.sha`.","Locally, set `HEAD_SHA=$(git rev-parse HEAD)` and fail the wrapper script if it is empty.","Add a preflight `case`/test in your CI shell that asserts both `--base-sha` and `--head-sha` are present in `$@` before invoking the .mjs."],"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"}