{"record":{"id":"19460917eb284d2e","repo":"nanocoai/nanoclaw","slug":"role-is-required","errorCode":null,"errorMessage":"--role is required","messagePattern":"--role is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/resources/roles.ts","lineNumber":62,"sourceCode":"             ON CONFLICT DO NOTHING`,\n          userId,\n          role,\n          groupId,\n          grantedBy,\n          new Date().toISOString(),\n        );\n        return { user_id: userId, role, agent_group_id: groupId };\n      },\n    },\n    revoke: {\n      access: 'approval',\n      description: 'Revoke a role. Use --user, --role, and --group if scoped.',\n      handler: async (args) => {\n        const userId = args.user as string;\n        const role = args.role as string;\n        const groupId = (args.group as string) ?? null;\n        if (!userId) throw new Error('--user is required');\n        if (!role) throw new Error('--role is required');\n        const result = await getDb().run(\n          'DELETE FROM user_roles WHERE user_id = ? AND role = ? AND agent_group_id IS NOT DISTINCT FROM ?',\n          userId,\n          role,\n          groupId,\n        );\n        if (result.changes === 0) throw new Error('role not found');\n        return { revoked: { user_id: userId, role, agent_group_id: groupId } };\n      },\n    },\n  },\n});\n","sourceCodeStart":44,"sourceCodeEnd":75,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/resources/roles.ts#L44-L75","documentation":"Thrown by the `ncl roles revoke` handler when `--user` was provided but `--role` is missing. The DELETE statement needs both the user and the role name to identify the exact `user_roles` row, so the CLI validates both before executing.","triggerScenarios":"Running `ncl roles revoke --user telegram:alice` with no --role. Passes the userId check, then fails on the empty role check.","commonSituations":"Assuming revoke with only --user removes all of that user's roles; typo'd flag names; passing a value like --role=Admin (this error is only about absence — invalid values simply match zero rows and raise 'role not found' instead).","solutions":["Add the role: `ncl roles revoke --user <id> --role owner` or `--role admin`","Check which roles the user currently holds with `ncl roles list --user <id>` (or `ncl roles list`) before revoking","Include --group when the role was granted group-scoped, otherwise the revoke targets the global row"],"exampleFix":"# before\nncl roles revoke --user telegram:alice\n# after\nncl roles revoke --user telegram:alice --role admin","handlingStrategy":"validation","validationCode":"if (!role || !['owner', 'admin'].includes(role)) {\n  throw new Error('roles revoke needs --role owner|admin');\n}\nawait execNcl(['roles', 'revoke', '--user', userId, '--role', role]);","typeGuard":"const isRoleName = (r: unknown): r is 'owner' | 'admin' => r === 'owner' || r === 'admin';","tryCatchPattern":"catch (e) { if (e.message === '--role is required') printUsageAndExit(1); else throw e; }","preventionTips":["Resolve current roles via `ncl roles list` before revoking","Type the role field as 'owner' | 'admin' in calling code","Reject empty role strings at the boundary of your script"],"tags":["cli","roles","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}