{"record":{"id":"3691ae19ff8b76db","repo":"nanocoai/nanoclaw","slug":"id-is-required","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/resources/groups.ts","lineNumber":214,"sourceCode":"        return getAgentGroupByFolder(folder);\n      },\n      // The restamp path returns a plan that wants the aligned-lines view;\n      // everything else keeps the generic JSON rendering.\n      formatHuman: (data) =>\n        data !== null && typeof data === 'object' && 'changes' in data && 'plugin' in data\n          ? formatRestampResult(data as RestampResult)\n          : JSON.stringify(localizeIsoTimestamps(data), null, 2),\n    },\n    delete: {\n      access: 'approval',\n      description:\n        'Delete an agent group and its dependent rows (sessions, destinations, approvals, role grants, ' +\n        'memberships, channel wirings). FK-ordered cascade in a single transaction. ' +\n        'Use --id <group-id>. Out of scope: killing running containers, on-disk cleanup of groups/<folder>/ and data/v2-sessions/<group-id>/. ' +\n        'The leftover groups/<folder>/ blocks re-creating a group under the same folder name until it is moved or removed.',\n      handler: async (args) => {\n        const id = args.id as string;\n        if (!id) throw new Error('--id is required');\n        const db = getDb();\n\n        // Verify the group exists before doing anything — preserves the\n        // genericDelete behaviour of throwing \"not found\" for unknown IDs.\n        const exists = await db.get('SELECT 1 FROM agent_groups WHERE id = ? LIMIT 1', id);\n        if (!exists) throw new Error(`group not found: ${id}`);\n\n        const hasAgentDestinations = await hasTable(db, 'agent_destinations');\n        const hasPendingApprovals = await hasTable(db, 'pending_approvals');\n\n        // FK-ordered cascade. The async driver transaction rolls\n        // back the whole thing if any statement throws (e.g. an FK constraint\n        // we missed), so the central DB stays consistent. The `removed` counts\n        // are sourced from each DELETE's `changes` so they describe exactly\n        // what the transaction did, not a separate pre-flight snapshot.\n        const removed = await db.transaction(async () => {\n          const counts = {\n            sessions: 0,","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/resources/groups.ts#L196-L232","documentation":"Thrown by `ncl groups delete` when no --id flag is given. Unlike agent-called commands, host-side delete has no caller context to auto-fill the group id from, so the id must be supplied explicitly.","triggerScenarios":"Running `ncl groups delete` with no --id, or a script whose --id variable expanded to empty (`ncl groups delete --id $GROUP_ID` with GROUP_ID unset).","commonSituations":"Shell scripts with unset/empty variables; operators assuming delete works on a 'current' or default group; CI jobs where the id lookup step failed silently and passed an empty string.","solutions":["Run `ncl groups list` to find the group id, then `ncl groups delete --id ag-<uuid>`","Quote and default-check script variables: `: \"${GROUP_ID:?GROUP_ID not set}\"`","Note delete does NOT remove groups/<folder>/ or data/v2-sessions/<group-id>/ — clean those up manually afterwards"],"exampleFix":"# before\nncl groups delete\n# after\nncl groups list\nncl groups delete --id ag-1234abcd-...","handlingStrategy":"validation","validationCode":": \"${GROUP_ID:?GROUP_ID not set}\"\nncl groups delete --id \"$GROUP_ID\"","typeGuard":"const isGroupId = (v: unknown): v is string => typeof v === 'string' && /^ag-[0-9a-f-]{36}$/.test(v);","tryCatchPattern":"try { await deleteGroup(id) } catch (e) { if (e instanceof Error && e.message === '--id is required') { /* usage bug, fix caller */ } throw e; }","preventionTips":["Always resolve the id from `ncl groups list` programmatically instead of hardcoding","Set shell 'unset variable' guards in delete scripts"],"tags":["cli","missing-argument","groups","delete"],"backgroundTag":"missing-required-argument","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}