{"record":{"id":"ad68b800be596117","repo":"ruvnet/ruflo","slug":"revoke-requires-an-approval-id","errorCode":null,"errorMessage":"revoke requires an approval id","messagePattern":"revoke requires an approval id","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/commands/policy.ts","lineNumber":96,"sourceCode":"        const rule = argJson<PolicyRule>(args[2], 'rule add');\n        await upsertPolicyRule(rule, root);\n        return print({ success: true, ruleId: rule.id });\n      }\n      if (operation === 'budget' && args[1] === 'set') {\n        requireInteractiveAdministrator();\n        const budget = argJson<BudgetLimit>(args[2], 'budget set');\n        await setPolicyBudget(budget, root);\n        return print({ success: true, budgetId: budget.id });\n      }\n      if (operation === 'approve') {\n        throw new Error(\n          'approval issuance requires an authenticated human identity adapter; '\n          + 'the local TTY is not an identity credential',\n        );\n      }\n      if (operation === 'revoke') {\n        requireInteractiveAdministrator();\n        if (!args[1]) throw new Error('revoke requires an approval id');\n        return print({ success: await revokePolicyApproval(args[1], root), approvalId: args[1] });\n      }\n      if (operation === 'audit') {\n        const state = loadPolicyState(root);\n        return print({ receipts: state.receipts });\n      }\n      if (operation === 'verify') return print(await verifyPolicyLedger(root));\n      throw new Error(`unknown policy operation: ${operation}`);\n    } catch (error) {\n      const message = error instanceof Error ? error.message : String(error);\n      output.printError(message);\n      return { success: false, exitCode: 1, data: { error: message } };\n    }\n  },\n  examples: [\n    { command: 'ruflo policy status', description: 'Show policy mode and ledger health' },\n    { command: 'ruflo policy init --mode observe', description: 'Migrate an existing install without blocking legacy actions' },\n    { command: 'ruflo policy budget set \\'{\"id\":\"daily-model\",\"action\":\"model.call\",\"maxCostUsd\":10,\"periodMs\":86400000}\\'', description: 'Set an atomic policy budget ceiling' },","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/commands/policy.ts#L78-L114","documentation":"Thrown by the revoke branch when args[1] (the approval identifier) is missing. Unlike approve, revoke is supported interactively, but it still needs the target approval id so the ledger records exactly which approval was withdrawn.","triggerScenarios":"Running `ruflo policy revoke` with no second positional token, or with the id accidentally placed in a flag the command does not read.","commonSituations":"Forgetting the id, copy-pasting only the verb, or passing `--id <x>` (a flag) instead of the positional the command expects.","solutions":["Look up the approval id first: `ruflo policy audit` prints the receipts list.","Pass the id as the positional argument: `ruflo policy revoke <approvalId>`.","Run from an interactive terminal — revoke also calls requireInteractiveAdministrator()."],"exampleFix":"// before\nruflo policy revoke\n// after\nruflo policy revoke appr_2024_08_12_abc","handlingStrategy":"validation","validationCode":"function resolveApprovalId(arg?: string): string {\n  if (!arg) throw new Error('revoke requires an approval id');\n  return arg;\n}\nresolveApprovalId(process.argv[3]); // throws before reaching the CLI","typeGuard":"const isApprovalId = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await revokePolicyApproval(id, root);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg === 'revoke requires an approval id') {\n    const ids = (await auditPolicy()).receipts.map(r => r.id);\n    console.error('Pass one of:', ids.join(', '));\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["List approvals with `policy audit` first.","Pass the id positionally, not as a flag.","Validate non-emptiness before invoking the CLI."],"tags":["cli","validation","policy"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}