{"record":{"id":"19e8196a3ac3f197","repo":"affaan-m/ECC","slug":"assigneekind-must-be-agent-or-human","errorCode":null,"errorMessage":"assigneeKind must be 'agent' or 'human'.","messagePattern":"assigneeKind must be 'agent' or 'human'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/control-pane/work-item-mutations.js","lineNumber":62,"sourceCode":"    }\n    return item;\n  }\n  const { items } = store.listWorkItems({ limit: 100 });\n  return items.filter(item => !item.owner && isOpenStatus(item.status)).sort((a, b) => priorityRank(a.priority) - priorityRank(b.priority))[0] || null;\n}\n\n/**\n * Claim an unassigned work item for an agent or human. Sets the owner (and\n * optional assigneeKind) and moves the card to running unless an explicit\n * status is supplied. Returns { claimed, item } or { claimed: false, reason }.\n */\nfunction claimWorkItem(store, { id, owner, assigneeKind, sessionId, status } = {}) {\n  if (!owner) {\n    throw new Error('claim requires an owner.');\n  }\n  const kind = assigneeKind ? String(assigneeKind).toLowerCase() : null;\n  if (kind && !VALID_ASSIGNEE_KINDS.has(kind)) {\n    throw new Error(\"assigneeKind must be 'agent' or 'human'.\");\n  }\n  const target = selectClaimTarget(store, { id });\n  if (!target) {\n    return { claimed: false, reason: 'no-unassigned-open-items' };\n  }\n  if (!isOpenStatus(target.status)) {\n    throw new Error(`Work item ${target.id} is already done; cannot claim.`);\n  }\n  const metadata = { ...(target.metadata || {}) };\n  if (kind) {\n    metadata.assigneeKind = kind;\n  }\n  const item = store.upsertWorkItem({\n    ...target,\n    owner,\n    sessionId: sessionId ?? target.sessionId ?? null,\n    status: status ?? 'running',\n    metadata,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/control-pane/work-item-mutations.js#L44-L80","documentation":"claimWorkItem accepts an optional assigneeKind that must be 'agent' or 'human' (case-insensitive). Any other non-empty value throws \"assigneeKind must be 'agent' or 'human'.\" This is an enum whitelist check before the store write.","triggerScenarios":"claimWorkItem(store, { id, owner, assigneeKind: 'bot' }) or assigneeKind: 'AI' with unexpected casing/wording; passing a role name ('reviewer') instead of the allowed kinds.","commonSituations":"Automation passing its tool name as assigneeKind; CLI flag typos (--assignee-knd); older scripts written before the assigneeKind option existed using freeform strings.","solutions":["Use exactly 'agent' or 'human' (any casing — it is lowercased before the check).","Remove the assigneeKind argument entirely if you don't need the distinction; it is optional.","Map your tool/role names to the allowed kinds before calling: bot/orchestrator → 'agent', person → 'human'.","Check VALID_ASSIGNEE_KINDS in work-item-mutations.js if the allowed set changes in a newer version."],"exampleFix":"// before\nclaimWorkItem(store, { id, owner: 'alice', assigneeKind: 'bot' });\n// after\nclaimWorkItem(store, { id, owner: 'alice', assigneeKind: 'agent' });","handlingStrategy":"validation","validationCode":"const VALID = new Set(['agent', 'human']);\nconst kind = assigneeKind ? String(assigneeKind).toLowerCase() : null;\nif (kind && !VALID.has(kind)) throw new Error(`assigneeKind must be agent|human, got ${assigneeKind}`);","typeGuard":"function isValidAssigneeKind(k) { return k == null || ['agent', 'human'].includes(String(k).toLowerCase()); }","tryCatchPattern":"try { claimWorkItem(store, { id, owner, assigneeKind }); } catch (e) {\n  if (e.message.includes(\"assigneeKind must be\")) return claimWorkItem(store, { id, owner });\n  throw e;\n}","preventionTips":["Only pass 'agent' or 'human'; map tool/role names before the call.","Omit assigneeKind when the distinction is unnecessary.","Keep a shared constant for allowed kinds instead of inline strings.","Re-check VALID_ASSIGNEE_KINDS after library upgrades."],"tags":["work-items","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}