jackwener/OpenCLI · error · ArgumentError
storage must be "local" or "session"
Error message
storage must be "local" or "session"
What it means
The storage-keys command accepts a --storage argument that must be exactly "local" or "session" (after trimming and lowercasing). ArgumentError is thrown for any other value, e.g. "localStorage", "Local", or "disk". This is a strict enum validation of the caller-supplied keyword argument.
Source
Thrown at clis/antigravity/storage.js:92
// ====== Renderer-side: storage-keys ======
cli({
site: 'antigravity',
name: 'storage-keys',
access: 'read',
description: 'List localStorage / sessionStorage keys on the Antigravity renderer (CDP).',
domain: '127.0.0.1',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'storage', required: false, default: 'local', help: '"local" or "session"' },
{ name: 'filter', required: false, help: 'Case-insensitive substring filter' },
{ name: 'limit', type: 'int', required: false, default: 100, help: 'Max rows to return' },
],
columns: STORAGE_COLUMNS,
func: async (page, kwargs) => {
const s = String(kwargs?.storage || 'local').trim().toLowerCase();
if (s !== 'local' && s !== 'session') throw new ArgumentError('storage', 'must be "local" or "session"');
const store = s === 'session' ? 'sessionStorage' : 'localStorage';
const raw = unwrapEvaluateResult(await page.evaluate(`(() => {
const s = ${store};
const out = [];
for (let i = 0; i < s.length; i++) {
const k = s.key(i); const v = s.getItem(k) || '';
out.push({ k, bytes: v.length });
}
return out;
})()`));
const flt = kwargs?.filter ? String(kwargs.filter).toLowerCase() : null;
const filtered = flt ? raw.filter((r) => r.k.toLowerCase().includes(flt)) : raw;
if (!filtered.length) throw new EmptyResultError('antigravity storage-keys', flt ? `No keys match "${flt}".` : `${store} is empty.`);
filtered.sort((a, b) => a.k.localeCompare(b.k));
const limit = Number.isInteger(kwargs?.limit) && kwargs.limit > 0 ? kwargs.limit : 100;
return filtered.slice(0, limit).map((r, i) => ({ Index: i + 1, Key: r.k, Bytes: r.bytes }));
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Use --storage local (default) or --storage session exactly.
- Omit --storage to get localStorage behavior.
- For IndexedDB use the separate `idb-list` command; for cookies use `cookies`.
- Normalize your script variable: value.trim().toLowerCase() before passing.
Example fix
// before opencli antigravity storage-keys --storage localStorage // after opencli antigravity storage-keys --storage local
Defensive patterns
Strategy: validation
Validate before calling
const storage = (process.argv.store || 'local').trim().toLowerCase();
if (!['local', 'session'].includes(storage)) throw new Error(`storage must be "local" or "session", got: ${storage}`); Type guard
function isStorageKind(v) {
return v === 'local' || v === 'session';
} Try / catch
try {
execSync(`opencli antigravity storage-keys --storage ${storage}`);
} catch (e) {
if (/storage must be "local" or "session"/.test(e.message)) {
console.error(`Bad --storage value; use local|session (got ${storage})`);
} else throw e;
} Prevention
- Use only the literal tokens 'local' and 'session'.
- normalize with trim().toLowerCase() in wrapper scripts before passing the flag.
- Omit the flag entirely to get the default (local).
- Remember IndexedDB and cookies have their own commands (idb-list, cookies).
When it happens
Trigger: Running `opencli antigravity storage-keys --storage localStorage`, `--storage SESSION` (uppercase not normalized before compare? it is lowercased, so only non-local/session strings fail), `--storage ''` resolves to default, but `--storage cache`, `--storage indexeddb` all throw.
Common situations: Typing the full Web API name 'localStorage' instead of 'local', guessing other stores like 'indexeddb' or 'cookie' are supported here, or scripting with a variable that holds the wrong token.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- key is required
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4d8c0f81caa6d11f.
Report an issue: GitHub.