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

  1. Pass a non-empty `key` kwarg, e.g. key="theme".
  2. Fix the kwarg spelling so the value lands in kwargs.key.
  3. Validate the upstream variable is non-empty before invoking.
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/619ed6ccdcb5f575. Report an issue: GitHub.