{"record":{"id":"513b0636c680af0e","repo":"saadeghi/daisyui","slug":"flag-requires-a-value-513b06","errorCode":null,"errorMessage":"${flag} requires a value","messagePattern":"(.+?) requires a value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/pr-preview.mjs","lineNumber":33,"sourceCode":"\nconst usage = `Usage:\n  bun packages/tailwind-play-share/pr-preview.mjs \\\\\n    --base-sha <sha> \\\\\n    --head-sha <sha> \\\\\n    --output <path>\n\nOptions:\n  --base-sha <sha>   Pull request base commit\n  --head-sha <sha>   Pull request head commit\n  --output <path>    Write the generated preview metadata as JSON\n  --browser <path>   Chrome/Chromium executable\n  --timeout <ms>     Timeout for each browser operation (default: ${defaultTimeoutMs})\n  --verbose          Write Tailwind Play progress information to stderr\n  --help             Show this help`\n\nfunction takeValue(argv, index, flag) {\n  const value = argv[index + 1]\n  if (value === undefined) throw new Error(`${flag} requires a value`)\n  return value\n}\n\nexport function parsePreviewArgs(argv) {\n  const options = {\n    baseSha: undefined,\n    browser: undefined,\n    headSha: undefined,\n    help: false,\n    output: undefined,\n    timeoutMs: defaultTimeoutMs,\n    verbose: false,\n  }\n\n  for (let index = 0; index < argv.length; index += 1) {\n    const argument = argv[index]\n    switch (argument) {\n      case \"--base-sha\":","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/pr-preview.mjs#L15-L51","documentation":"Thrown by takeValue in pr-preview.mjs when a flag that expects a value (--base-sha, --head-sha, --output, --browser, or --timeout) is the last token on the command line, so argv[index + 1] is undefined.","triggerScenarios":"Invoking pr-preview.mjs with e.g. `--base-sha` and nothing after it, or the value being consumed as a different flag.","commonSituations":"A copy/paste CLI invocation missing the SHA, a shell that swallowed the value due to unquoted expansion, or a CI step that interpolates an empty variable (`--base-sha ${{ github.event.pull_request.base.sha }}` when empty).","solutions":["Provide the value immediately after the flag: `--base-sha <sha>`.","Quote the argument so the shell does not drop empty values.","Run with --help to see the expected option shape."],"exampleFix":"// before\nbun packages/tailwind-play-share/pr-preview.mjs --base-sha --head-sha abc --output out.json\n\n// after\nbun packages/tailwind-play-share/pr-preview.mjs --base-sha def --head-sha abc --output out.json","handlingStrategy":"validation","validationCode":"function flagHasValue(argv, flagIndex) {\n  return argv[flagIndex + 1] !== undefined && !argv[flagIndex + 1].startsWith(\"--\")\n}","typeGuard":null,"tryCatchPattern":"try {\n  options = parsePreviewArgs(argv)\n} catch (error) {\n  if (/requires a value$/.test(error.message)) {\n  // show usage and exit with a clear error\n  }\n  throw error\n}","preventionTips":["Always pass a value immediately after each value-taking flag.","Quote interpolated values in CI to avoid dropping empty SHAs.","Validate argv shape before invoking parsePreviewArgs."],"tags":["cli","argv","argument-parsing"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}