{"record":{"id":"13be4a499c777637","repo":"nanocoai/nanoclaw","slug":"target-agent-group-not-found-to","errorCode":null,"errorMessage":"target agent group not found: ${to}","messagePattern":"target agent group not found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/resources/policies.ts","lineNumber":37,"sourceCode":"    },\n    { name: 'created_at', type: 'string', description: 'Auto-set.' },\n  ],\n  operations: { list: 'open' },\n  customOperations: {\n    set: {\n      access: 'approval',\n      description:\n        'Require approval for messages from one agent to another. Use --from <agent-group-id> --to <agent-group-id> --approver <user-id>. Only the named approver (or an owner) can approve.',\n      handler: async (args) => {\n        const from = args.from as string;\n        const to = args.to as string;\n        const approver = args.approver as string;\n        if (!from) throw new Error('--from is required');\n        if (!to) throw new Error('--to is required');\n        if (!approver) throw new Error('--approver is required');\n        if (from === to) throw new Error('--from and --to must differ (self-messages are never gated)');\n        if (!(await getAgentGroup(from))) throw new Error(`source agent group not found: ${from}`);\n        if (!(await getAgentGroup(to))) throw new Error(`target agent group not found: ${to}`);\n\n        await setMessagePolicy(from, to, approver, new Date().toISOString());\n        return { from_agent_group_id: from, to_agent_group_id: to, approver };\n      },\n    },\n    remove: {\n      access: 'approval',\n      description: 'Remove an approval policy (back to free flow). Use --from <agent-group-id> --to <agent-group-id>.',\n      handler: async (args) => {\n        const from = args.from as string;\n        const to = args.to as string;\n        if (!from) throw new Error('--from is required');\n        if (!to) throw new Error('--to is required');\n        if (!(await removeMessagePolicy(from, to))) throw new Error('policy not found');\n        return { removed: { from_agent_group_id: from, to_agent_group_id: to } };\n      },\n    },\n  },","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/resources/policies.ts#L19-L55","documentation":"Thrown by `ncl policies set` when getAgentGroup(to) returns null — the target agent group id passed via --to does not exist. Same existence check as the source, applied to the policy's destination side.","triggerScenarios":"Typo in --to; target group deleted; wrong id namespace (folder name vs DB id).","commonSituations":"Same as source-not-found: stale references and id confusion.","solutions":["Run `ncl groups list` and use the exact --to id","Recreate the target group if it was removed but still needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const groups = await listAgentGroups(); if (!groups.some(g => g.id === to)) throw new Error(`unknown target group ${to}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both endpoints against `ncl groups list` before setting policies","Watch for stale ids in long-lived scripts"],"tags":["cli","not-found","policies","agent-groups"],"backgroundTag":"entity-not-found","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}