jackwener/OpenCLI · error · ArgumentError
is required
Error message
is required
What it means
An ArgumentError thrown by the `storage-get` command when the `key` kwarg is missing, an empty string, or only whitespace after trimming. Web Storage reads require a concrete key, so the command fails fast before touching the page.
Source
Thrown at clis/trae-solo/renderer-storage.js:92
// -------- storage-get --------
cli({
site: 'trae-solo',
name: 'storage-get',
access: 'read',
description: 'Read a single localStorage / sessionStorage value on the Trae SOLO renderer.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'key', positional: true, required: true, help: 'Storage key (use storage-keys to discover)' },
{ name: 'storage', required: false, default: 'local', help: '"local" or "session"' },
{ name: 'max-bytes', type: 'int', required: false, default: 4000, help: 'Truncate value to this many chars' },
],
columns: ['Field', 'Value'],
func: async (page, kwargs) => {
const key = String(kwargs?.key || '').trim();
if (!key) throw new ArgumentError('key', 'is required');
const store = pickStore(kwargs);
const raw = await page.evaluate(`${store}.getItem(${JSON.stringify(key)})`);
if (raw === null) throw new CommandExecutionError(`Key not found in ${store}: ${key}`, '');
const max = Number.isInteger(kwargs['max-bytes']) && kwargs['max-bytes'] > 0 ? kwargs['max-bytes'] : 4000;
let parsed = raw, kind = 'string';
try { parsed = JSON.parse(raw); kind = Array.isArray(parsed) ? 'array' : typeof parsed; } catch {}
const text = kind === 'string' ? parsed : JSON.stringify(parsed, null, 2);
const truncated = text.length > max;
return [
{ Field: 'Key', Value: key },
{ Field: 'Store', Value: store },
{ Field: 'Type', Value: kind },
{ Field: 'Size', Value: `${text.length} chars${truncated ? ' (truncated)' : ''}` },
{ Field: 'Value', Value: truncated ? text.slice(0, max) + '\n...(truncated)' : text },
];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty `key` kwarg, e.g. key="theme".
- Fix the kwarg spelling so the value lands in kwargs.key.
- Validate the upstream variable is non-empty before invoking.
- Run storage-keys first to confirm the exact key name.
Example fix
// before
await cli('trae-solo', 'storage-get', {});
// after
const key = process.env.STORAGE_KEY;
if (!key) throw new Error('STORAGE_KEY not set');
await cli('trae-solo', 'storage-get', { key }); Defensive patterns
Strategy: validation
Validate before calling
const key = String(kwargs.key ?? '').trim();
if (!key) throw new Error('storage-get requires a non-empty key kwarg'); Type guard
const hasKey = (kwargs) => typeof kwargs?.key === 'string' && kwargs.key.trim().length > 0;
Try / catch
try {
await cli('trae-solo', 'storage-get', { key });
} catch (e) {
if (/is required/.test(e.message) && /key/.test(e.message + '')) {
console.error('Missing key. Usage: storage-get key=<name>');
} else throw e;
} Prevention
- Validate variables holding key names are non-empty before invoking.
- Always pass key as a named kwarg, not positionally.
- Trim user-supplied keys and reject whitespace-only values early.
- Consult storage-keys output to confirm key names before reads.
When it happens
Trigger: Calling storage-get without `key`, with key:'' , key:' ', or with a mistyped kwarg name (e.g. `name=` or `k=`) so kwargs.key is undefined.
Common situations: Scripting pipelines where a variable holding the key name is empty; copying commands from docs and forgetting the required kwarg; passing the value positionally when the command expects a named kwarg.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- storage
- <train-no> must not be empty
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/619ed6ccdcb5f575.
Report an issue: GitHub.