{"record":{"id":"ead6c0116342719c","repo":"affaan-m/ECC","slug":"unknown-argument-arg-ead6c0","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/preview-pack-smoke.js","lineNumber":140,"sourceCode":"    }\n\n    if (arg.startsWith('--format=')) {\n      parsed.format = arg.slice('--format='.length).toLowerCase();\n      continue;\n    }\n\n    if (arg === '--root') {\n      parsed.root = path.resolve(readArgValue(args, index, arg));\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);\n  }\n\n  return parsed;\n}\n\nfunction readText(rootDir, relativePath) {\n  try {\n    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');\n  } catch (_error) {\n    return '';\n  }\n}\n\nfunction fileExists(rootDir, relativePath) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/preview-pack-smoke.js#L122-L158","documentation":"Thrown at the end of preview-pack-smoke's parseArgs loop when a token matched none of the recognized flags (--help/-h, --format(+==), --json, --root(+==)). The parser is intentionally strict because this is a deterministic smoke gate: unrecognized input would make the result non-reproducible.","triggerScenarios":"A typo such as `--fromat`; passing a positional path instead of `--root`; a flag from a different script copied in; shell glob inserting an unexpected token.","commonSituations":"User copies flags from platform-audit (which has many more) into preview-pack-smoke; version mismatch where a flag was renamed.","solutions":["Run `--help` to see the two accepted value flags for this script.","Use `--root=<dir>` to pass the repo root; this script only takes --format and --root.","Quote arguments and verify no shell expansion injected stray tokens."],"exampleFix":"# before\nnode scripts/preview-pack-smoke.js --fromat json\n# after\nnode scripts/preview-pack-smoke.js --format json","handlingStrategy":"validation","validationCode":"const PREVIEW_FLAGS = new Set(['--help','-h','--format','--json','--root']);\nfunction isPreviewFlag(token) {\n  const base = token.split('=')[0];\n  return PREVIEW_FLAGS.has(base);\n}","typeGuard":"function isKnownPreviewFlag(token) {\n  const base = token.startsWith('--') ? token.split('=')[0] : token;\n  return PREVIEW_FLAGS.has(base);\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Unknown argument')) {\n    console.error(`${err.message}. preview-pack-smoke only accepts --format and --root.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Only --format and --root are valid here; do not copy flags from other scripts.","Run --help to confirm the accepted surface.","Quote path arguments to avoid token splitting."],"tags":["cli","argument-validation","preview-pack-smoke"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}