{"record":{"id":"8e401c5f7e76c361","repo":"jackwener/OpenCLI","slug":"must-be-local-or-session","errorCode":null,"errorMessage":"must be \"local\" or \"session\"","messagePattern":"must be \"local\" or \"session\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/kimi/storage.js","lineNumber":21,"sourceCode":"//   storage-keys [--storage local|session] [--filter]\n//   storage-get <key> [--storage] [--max-bytes]\n//   cookies         — list JS-visible cookies\n//   idb-list        — list IndexedDB databases on kimi.com\n\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport {\n    ArgumentError,\n    CommandExecutionError,\n    EmptyResultError,\n} from '@jackwener/opencli/errors';\nimport { KIMI_DOMAIN, ensureOnKimi } from './_utils.js';\n\nconst STORAGE_COLUMNS = ['Field', 'Value', 'Index', 'Key', 'Bytes', 'Name', 'Preview', 'Database', 'Version'];\n\nfunction pickStore(args) {\n    const s = String(args?.storage || 'local').trim().toLowerCase();\n    if (s !== 'local' && s !== 'session') {\n        throw new ArgumentError('storage', 'must be \"local\" or \"session\"');\n    }\n    return s === 'session' ? 'sessionStorage' : 'localStorage';\n}\n\n// -------- storage-keys --------\ncli({\n    site: 'kimi',\n    name: 'storage-keys',\n    access: 'read',\n    description: 'List localStorage / sessionStorage keys on kimi.com (with byte sizes).',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'storage', required: false, default: 'local', help: '\"local\" or \"session\"' },\n        { name: 'filter', required: false, help: 'Case-insensitive substring filter over keys' },","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/storage.js#L3-L39","documentation":"ArgumentError raised by pickStore in clis/kimi/storage.js when the 'storage' argument is neither 'local' nor 'session' (case-insensitive). pickStore normalizes the value and maps it to localStorage/sessionStorage; anything else is rejected. It is reached through the store-reading storage commands.","triggerScenarios":"Calling a kimi storage command (e.g. storage-keys, storage-get) with --storage anything other than local/session, such as 'cookies', 'Local' misspellings like 'loca', 'sessionstorage', or an empty-but-nondefault value.","commonSituations":"Confusing the storage flag with the separate cookies command, typos in the enum value, or scripts passing a variable that holds an unsupported storage name.","solutions":["Use --storage local or --storage session exactly (case-insensitive)","Omit the flag entirely to get the default 'local'","Validate user-supplied storage names in your wrapper before calling the CLI"],"exampleFix":"// before\nawait kimi(['storage', 'keys', '--storage', 'cookie']);\n// after\nawait kimi(['storage', 'keys', '--storage', 'local']);\n// or use the cookies command for cookie data:\nawait kimi(['storage', 'cookies']);","handlingStrategy":"validation","validationCode":"function assertStorage(s) {\n  const v = String(s ?? 'local').trim().toLowerCase();\n  if (v !== 'local' && v !== 'session') throw new Error(`--storage must be \"local\" or \"session\", got \"${s}\"`);\n  return v;\n}\nassertStorage(userInput.storage);","typeGuard":"const isStorageKind = (v) => v === 'local' || v === 'session' || v === 'sessionStorage' || v === 'localStorage';","tryCatchPattern":"try {\n  await kimi(['storage', 'keys', '--storage', opts.storage]);\n} catch (e) {\n  if (/must be \"local\" or \"session\"/.test(e.message)) {\n    console.error('Allowed values: local, session');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Whitelist the two enum values in your wrapper","Default to 'local' by omitting the flag","Don't confuse the cookies command with the storage flag","Normalize user input (trim + lowercase) before passing it"],"tags":["argument-validation","invalid-enum","kimi"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}