{"record":{"id":"9727d15a45fd751f","repo":"affaan-m/ECC","slug":"as-must-be-agent-or-human","errorCode":null,"errorMessage":"--as must be 'agent' or 'human'.","messagePattern":"--as must be 'agent' or 'human'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":400,"sourceCode":"  console.log(`  Closed stale items: ${payload.closedCount}`);\n  if (payload.items.length === 0 && payload.closedItems.length === 0) {\n    console.log('  Work items changed: none');\n    return;\n  }\n  for (const item of [...payload.items, ...payload.closedItems]) {\n    console.log(`  - ${item.id} ${item.status}: ${item.title}`);\n  }\n}\n\n// Thin CLI adapter over the shared claimWorkItem helper, preserving the\n// flag-specific error messages (--owner / --as) for the command line.\nfunction claimWorkItemCli(store, options) {\n  if (!options.owner) {\n    throw new Error('claim requires --owner <name>.');\n  }\n  const assigneeKind = options.claimAs ? String(options.claimAs).toLowerCase() : null;\n  if (assigneeKind && assigneeKind !== 'agent' && assigneeKind !== 'human') {\n    throw new Error(\"--as must be 'agent' or 'human'.\");\n  }\n  return claimWorkItem(store, {\n    id: resolveWorkItemId(options),\n    owner: options.owner,\n    assigneeKind,\n    sessionId: options.sessionId,\n    status: options.status\n  });\n}\n\nasync function main() {\n  let store = null;\n\n  try {\n    const options = parseArgs(process.argv);\n    if (options.help) {\n      showHelp(0);\n    }","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L382-L418","documentation":"Thrown by claimWorkItemCli() when options.claimAs is set but, after lowercasing, is neither 'agent' nor 'human'. The assigneeKind is forwarded to the shared claimWorkItem helper which records it on the item, so the value must be one of the two supported kinds. A null/undefined claimAs is allowed (no kind recorded); only a wrong value is rejected.","triggerScenarios":"Running claim with --as set to anything other than agent/human, e.g. `--as bot`, `--as AGENT` (ok, case-insensitive), `--as user`. Comparison is lowercased, so 'Agent' and 'Human' pass; 'users' or 'auto' do not.","commonSituations":"Typing --as user instead of --as human; passing a free-form role; assuming the flag accepts arbitrary assignee types.","solutions":["Use exactly agent or human: `claim <id> --owner alice --as human`.","Drop the --as flag entirely if you do not need to record a kind.","Remember the check is case-insensitive, so 'Agent' / 'HUMAN' also work."],"exampleFix":"// before\nnode scripts/work-items.js claim refactor-state-store --owner alice --as user\n\n// after\nnode scripts/work-items.js claim refactor-state-store --owner alice --as human","handlingStrategy":"validation","validationCode":"function normalizeClaimAs(value) {\n  if (value === undefined || value === null || value === '') return null;\n  const kind = String(value).toLowerCase();\n  if (kind !== 'agent' && kind !== 'human') {\n    throw new Error(\"--as must be 'agent' or 'human'\");\n  }\n  return kind;\n}\n// call before claimWorkItemCli: options.claimAs = normalizeClaimAs(options.claimAs);","typeGuard":"function isClaimAs(value) {\n  if (value === undefined || value === null || value === '') return true;\n  const k = String(value).toLowerCase();\n  return k === 'agent' || k === 'human';\n}","tryCatchPattern":null,"preventionTips":["Whitelist --as to agent/human in any wrapper script.","Remember the check is case-insensitive, so normalize before comparing.","Drop the flag entirely when you do not need a kind rather than passing a placeholder."],"tags":["cli","validation","invalid-value","claim","assignee"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}