{"record":{"id":"2501cf65036aa560","repo":"nanocoai/nanoclaw","slug":"policy-not-found","errorCode":null,"errorMessage":"policy not found","messagePattern":"policy not found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/resources/policies.ts","lineNumber":51,"sourceCode":"        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  },\n});\n","sourceCodeStart":33,"sourceCodeEnd":57,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/resources/policies.ts#L33-L57","documentation":"Thrown by `ncl policies remove` when removeMessagePolicy(from, to) returns false — no message_policies row exists for that (from, to) pair, so there was nothing to delete.","triggerScenarios":"The policy was already removed, was never set for that exact pair, or one of the ids is wrong.","commonSituations":"Re-running an idempotent cleanup script; policy was set with a different from/to direction (policies are directional).","solutions":["Check which policies exist (ncl policies list) before removing","Confirm the direction: the pair must match how the policy was set exactly","If already gone, the desired end state is reached — continue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const exists = await getMessagePolicy(from, to); if (!exists) { /* nothing to remove */ }","typeGuard":null,"tryCatchPattern":"try { await removePolicy(from, to); } catch (e) { if (e.message === 'policy not found') return; throw e; }","preventionTips":["List policies before removing","Remember policies are directional — match the original pair"],"tags":["cli","not-found","policies","idempotency"],"backgroundTag":"entity-not-found","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}