{"record":{"id":"e35c42f14efa90bf","repo":"jackwener/OpenCLI","slug":"is-required-e35c42","errorCode":null,"errorMessage":"is required","messagePattern":"is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/kimi/storage.js","lineNumber":86,"sourceCode":"cli({\n    site: 'kimi',\n    name: 'storage-get',\n    access: 'read',\n    description: 'Read a single localStorage / sessionStorage value on kimi.com. Auto-decodes JSON.',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'key', positional: true, required: true, help: 'Storage key' },\n        { name: 'storage', required: false, default: 'local' },\n        { name: 'max-bytes', type: 'int', required: false, default: 4000 },\n    ],\n    columns: STORAGE_COLUMNS,\n    func: async (page, kwargs) => {\n        const key = String(kwargs?.key || '').trim();\n        if (!key) throw new ArgumentError('key', 'is required');\n        await ensureOnKimi(page);\n        const store = pickStore(kwargs);\n        const raw = await page.evaluate(`${store}.getItem(${JSON.stringify(key)})`);\n        if (raw === null || raw === undefined) {\n            throw new CommandExecutionError(`Key not found in ${store}: ${key}`, '');\n        }\n        const max = Number.isInteger(kwargs['max-bytes']) && kwargs['max-bytes'] > 0 ? kwargs['max-bytes'] : 4000;\n        let parsed = raw;\n        let kind = 'string';\n        try {\n            parsed = JSON.parse(raw);\n            kind = Array.isArray(parsed) ? 'array' : typeof parsed;\n        } catch {}\n        const text = kind === 'string' ? parsed : JSON.stringify(parsed, null, 2);\n        const truncated = text.length > max;\n        return [\n            { Field: 'Key', Value: key },\n            { Field: 'Store', Value: store },","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/storage.js#L68-L104","documentation":"ArgumentError thrown by the kimi storage get command when the required 'key' argument is missing or trims to an empty string. The func re-checks the positional/flag value defensively before touching the page.","triggerScenarios":"Calling `kimi storage get` without --key, with --key \"\", or with a whitespace-only value so String(kwargs?.key||'').trim() is empty.","commonSituations":"Shell quoting dropping the argument, a wrapper passing an empty variable, or forgetting that key is required while storage (default 'local') is optional.","solutions":["Pass the key explicitly: kimi storage get --key \"myKey\"","Check shell quoting/variable expansion so the key isn't lost","Validate the key is non-empty in your wrapper before invoking"],"exampleFix":"// before\nconst key = cfg.storageKey; // may be undefined\nawait kimi(['storage', 'get', '--key', key]);\n// after\nif (!cfg.storageKey) throw new Error('cfg.storageKey is required');\nawait kimi(['storage', 'get', '--key', cfg.storageKey]);","handlingStrategy":"validation","validationCode":"function assertKey(key) {\n  const k = String(key ?? '').trim();\n  if (!k) throw new Error('storage get requires --key');\n  return k;\n}\nassertKey(opts.key);","typeGuard":"const hasKey = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await kimi(['storage', 'get', '--key', key]);\n} catch (e) {\n  if (/is required/.test(e.message) && /key/.test(e.message)) {\n    console.error('Usage: kimi storage get --key <key> [--storage local|session]');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Always pass --key explicitly","Validate non-empty key in wrapper scripts","Quote shell arguments to avoid silent drops","Remember storage has a default; key does not"],"tags":["argument-validation","cli-usage","kimi"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}