{"record":{"id":"aad11e19cfac61f2","repo":"jackwener/OpenCLI","slug":"key-not-found-in-store-key-aad11e","errorCode":null,"errorMessage":"Key not found in ${store}: ${key}","messagePattern":"Key not found in (.+?): (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/renderer-storage.js","lineNumber":95,"sourceCode":"    site: 'trae-solo',\n    name: 'storage-get',\n    access: 'read',\n    description: 'Read a single localStorage / sessionStorage value on the Trae SOLO renderer.',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'key', positional: true, required: true, help: 'Storage key (use storage-keys to discover)' },\n        { name: 'storage', required: false, default: 'local', help: '\"local\" or \"session\"' },\n        { name: 'max-bytes', type: 'int', required: false, default: 4000, help: 'Truncate value to this many chars' },\n    ],\n    columns: ['Field', 'Value'],\n    func: async (page, kwargs) => {\n        const key = String(kwargs?.key || '').trim();\n        if (!key) throw new ArgumentError('key', 'is required');\n        const store = pickStore(kwargs);\n        const raw = await page.evaluate(`${store}.getItem(${JSON.stringify(key)})`);\n        if (raw === null) throw new CommandExecutionError(`Key not found in ${store}: ${key}`, '');\n        const max = Number.isInteger(kwargs['max-bytes']) && kwargs['max-bytes'] > 0 ? kwargs['max-bytes'] : 4000;\n        let parsed = raw, kind = 'string';\n        try { parsed = JSON.parse(raw); kind = Array.isArray(parsed) ? 'array' : typeof parsed; } 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 },\n            { Field: 'Type', Value: kind },\n            { Field: 'Size', Value: `${text.length} chars${truncated ? ' (truncated)' : ''}` },\n            { Field: 'Value', Value: truncated ? text.slice(0, max) + '\\n...(truncated)' : text },\n        ];\n    },\n});\n\n// -------- cookies --------\ncli({\n    site: 'trae-solo',","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/renderer-storage.js#L77-L113","documentation":"CommandExecutionError from `storage-get` when `localStorage`/`sessionStorage.getItem(key)` returns null in the Trae renderer, i.e. the key does not exist in the selected storage area at read time. The error message embeds both the store name and the requested key.","triggerScenarios":"Reading a key that was never written, was deleted (logout clears session data), exists only in sessionStorage while reading localStorage (default) or vice versa, or key name differs in case/spelling — Web Storage keys are case-sensitive.","commonSituations":"Assuming a token is in localStorage when the app uses sessionStorage; inspecting before login/first-run wrote the key; Trae updated and renamed internal keys; reading the wrong window/page state.","solutions":["Confirm the exact key with storage-keys (try both storage=local and storage=session).","Check key spelling and case — getItem is case-sensitive.","Trigger the app action that writes the key (log in, change a setting) before reading.","Add a fallback that tries the other storage area before giving up."],"exampleFix":"// before\nconst v = await cli('trae-solo', 'storage-get', { key: 'authToken' });\n// after\nfunction get(store) { return cli('trae-solo', 'storage-get', { key: 'authToken', storage: store }); }\nlet v; try { v = await get('local'); } catch { v = await get('session'); }","handlingStrategy":"fallback","validationCode":"const keys = await cli('trae-solo', 'storage-keys', { storage });\nif (!keys.some(k => k.Key === key)) {\n  throw new Error(`'${key}' not in ${storage}. Existing: ${keys.map(k => k.Key).join(', ')}`);\n}","typeGuard":"const keyExists = (rows, key) =>\n  Array.isArray(rows) && rows.some(r => r.Key === key);","tryCatchPattern":"try {\n  val = await cli('trae-solo', 'storage-get', { key, storage: 'local' });\n} catch (e) {\n  if (/Key not found/.test(e.message)) {\n    val = await cli('trae-solo', 'storage-get', { key, storage: 'session' });\n  } else throw e;\n}","preventionTips":["Remember Web Storage keys are case-sensitive — copy exact names from storage-keys.","Try both local and session stores before concluding the key is absent.","Trigger the app flow that writes the key before reading it.","Treat logout/settings-reset as key-clearing events in scripts."],"tags":["key-not-found","storage","trae"],"backgroundTag":"storage-key-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}