{"record":{"id":"464786072eb2f936","repo":"ruvnet/ruflo","slug":"invalid-target-format-target-use-agent-id-o","errorCode":null,"errorMessage":"Invalid target format: ${target}. Use agent:<id> or human:<id>","messagePattern":"Invalid target format: (.+?)\\. Use agent:<id> or human:<id>","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/claims/src/api/cli-commands.ts","lineNumber":174,"sourceCode":"  }\n\n  const hours = Math.floor(diffMs / (1000 * 60 * 60));\n  const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));\n\n  if (hours < 1) {\n    return output.warning(`${minutes}m`);\n  } else if (hours < 4) {\n    return output.warning(`${hours}h ${minutes}m`);\n  }\n\n  return output.dim(`${hours}h ${minutes}m`);\n}\n\nfunction parseTarget(target: string): { id: string; type: ClaimantType } {\n  // Format: agent:coder-1 or human:alice\n  const [type, id] = target.split(':');\n  if (!type || !id || (type !== 'agent' && type !== 'human')) {\n    throw new Error(`Invalid target format: ${target}. Use agent:<id> or human:<id>`);\n  }\n  return { id, type: type as ClaimantType };\n}\n\n// ============================================\n// List Subcommand\n// ============================================\n\nconst listCommand: Command = {\n  name: 'list',\n  aliases: ['ls'],\n  description: 'List issues',\n  options: [\n    {\n      name: 'available',\n      short: 'a',\n      description: 'Show only unclaimed issues',\n      type: 'boolean',","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/claims/src/api/cli-commands.ts#L156-L192","documentation":"Thrown by parseTarget in the @claude-flow/claims CLI when a claimant target string cannot be parsed as 'agent:<id>' or 'human:<id>'. The string is split on ':' and both halves must be present with type exactly 'agent' or 'human'; anything else (missing colon, unknown prefix, empty id) is rejected before any claim operation runs.","triggerScenarios":"Running a claims CLI command with --target coder-1 (no prefix), --target agent: (empty id), --target user:alice (unknown type 'user'), or --target 'agent:alice' when the intended prefix was human. Also targets containing extra colons silently truncate the id to the first segment, so malformed composite ids can fail downstream or here.","commonSituations":"Copy-pasting an id from a list output that shows bare names; scripts building targets via string concatenation with an undefined type variable; onboarding confusion about whether a claimant is registered as agent or human.","solutions":["Re-run the command with an explicit prefix, e.g. --target agent:coder-1 or --target human:alice","Check the claimant's registered type via the claims list/users command and use the matching prefix","Fix the script that assembles the target string to always emit `${type}:${id}` with type validated against ['agent','human']"],"exampleFix":"# before\nclaims grant --target coder-1 --capability deploy\n# throws: Invalid target format: coder-1. Use agent:<id> or human:<id>\n\n# after\nclaims grant --target agent:coder-1 --capability deploy","handlingStrategy":"type-guard","validationCode":"const TARGET_RE = /^(agent|human):(.+)$/;\nif (!TARGET_RE.test(target)) {\n  throw new Error(`target must match agent:<id> or human:<id>, got: ${target}`);\n}","typeGuard":"function parseTargetSafe(target: string): { id: string; type: 'agent' | 'human' } | null {\n  const m = /^(agent|human):([^:]+)$/.exec(target.trim());\n  return m ? { type: m[1] as 'agent' | 'human', id: m[2] } : null;\n}","tryCatchPattern":null,"preventionTips":["Build targets from typed values: `${type}:${id}` with type from a union","Validate target strings with a regex before passing to the claims CLI"],"tags":["cli","claims","argument-parsing","input-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}