{"record":{"id":"1044d98609ebc534","repo":"Egonex-AI/Understand-Anything","slug":"exclude-requires-patterns","errorCode":null,"errorMessage":"--exclude requires patterns","messagePattern":"--exclude requires patterns","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/prepare-incremental.mjs","lineNumber":460,"sourceCode":"  const edges = (graph?.edges ?? []).filter(\n    edge =>\n      !removedNodeIds.has(edge.source)\n      && !removedNodeIds.has(edge.target)\n      && !(edge.type === 'imports' && refreshedImportSourceIds.has(edge.source))\n      && retainedIds.has(edge.source)\n      && retainedIds.has(edge.target),\n  );\n  return { nodes, edges };\n}\n\nfunction parseArgs(argv) {\n  const positionals = [];\n  const excludePatterns = [];\n  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i];\n    if (arg === '--exclude') {\n      const value = argv[++i];\n      if (!value || value.startsWith('--')) throw new Error('--exclude requires patterns');\n      excludePatterns.push(...value.split(',').map(item => item.trim()).filter(Boolean));\n    } else if (arg.startsWith('--')) {\n      throw new Error(`Unknown option: ${arg}`);\n    } else {\n      positionals.push(arg);\n    }\n  }\n  if (positionals.length !== 2) {\n    throw new Error(\n      'Usage: node prepare-incremental.mjs <projectRoot> <baseCommit> [--exclude <patterns>]',\n    );\n  }\n  return { projectRoot: positionals[0], baseCommit: positionals[1], excludePatterns };\n}\n\nasync function main() {\n  const args = parseArgs(process.argv.slice(2));\n  const projectRoot = realpathSync(args.projectRoot);","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/prepare-incremental.mjs#L442-L478","documentation":"parseArgs validates CLI arguments for prepare-incremental.mjs. The --exclude flag was given but the next argument is missing or itself starts with '--', so there is no pattern value to consume, and the script stops with a usage error rather than silently excluding nothing.","triggerScenarios":"Running `node prepare-incremental.mjs <root> <commit> --exclude` with no value, or `--exclude --other-flag`, or `--exclude` as the last argument before the end of argv.","commonSituations":"Typing the flag without its value, copy-pasting a command where the pattern list was dropped, or intending a flag whose name begins with -- right after --exclude.","solutions":["Pass the patterns immediately after --exclude, e.g. --exclude 'dist,test-fixtures'","Use comma-separated patterns in a single value: --exclude 'build,node_modules'","Quote patterns so shell splitting does not separate them unexpectedly","Check the command in your script/CI config for a missing or mis-quoted value"],"exampleFix":"// before\nnode prepare-incremental.mjs . HEAD --exclude\n// after\nnode prepare-incremental.mjs . HEAD --exclude dist,coverage","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nconst idx = args.indexOf('--exclude');\nif (idx !== -1 && (idx + 1 >= args.length || args[idx + 1].startsWith('--'))) {\n  throw new Error('--exclude requires patterns');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message === '--exclude requires patterns') {\n    console.error('Usage: node prepare-incremental.mjs <projectRoot> <baseCommit> [--exclude <patterns>]');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always pass a value immediately after --exclude","Use one comma-separated quoted value: --exclude 'dist,coverage'","Verify scripted/CI invocations keep the pattern argument intact"],"tags":["cli","arguments"],"backgroundTag":"missing-required-flag","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}