{"record":{"id":"bcf4aa1aa336c697","repo":"jackwener/OpenCLI","slug":"query-bcf4aa","errorCode":null,"errorMessage":"query","messagePattern":"query","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qoder/ui.js","lineNumber":75,"sourceCode":"});\n\n// -------- search --------\ncli({\n    site: 'qoder',\n    name: 'search',\n    access: 'read',\n    description: 'Open Qoder Search palette (⌘P), type a query, return matched options.',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'query', positional: true, required: true, help: 'Search text' },\n        { name: 'limit', type: 'int', required: false, default: 20 },\n    ],\n    columns: ['Index', 'Item'],\n    func: async (page, kwargs) => {\n        const query = String(kwargs?.query || '').trim();\n        if (!query) throw new ArgumentError('query', 'is required');\n        const limit = parsePositiveInt(kwargs?.limit, 20, '--limit');\n        const openRes = await evaluateQoder(page, clickByTextScript(['Search']));\n        if (!openRes?.ok) throw new CommandExecutionError(openRes?.reason || 'search open failed', '');\n        await page.wait(0.5);\n        // Type into the visible input (usually the most-recently mounted one).\n        const fillRes = await evaluateQoder(page, `(() => {\n      ${IS_VISIBLE_JS}\n      const inputs = Array.from(document.querySelectorAll('input[type=\"text\"], input[type=\"search\"], input:not([type])')).filter(isVisible);\n      const input = inputs[inputs.length - 1];\n      if (!input) return { ok: false, reason: 'No input visible.' };\n      const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;\n      setter.call(input, ${JSON.stringify(query)});\n      input.dispatchEvent(new Event('input', { bubbles: true }));\n      input.dispatchEvent(new Event('change', { bubbles: true }));\n      return { ok: true };\n    })()`);\n        if (!fillRes?.ok) throw new CommandExecutionError(fillRes?.reason || 'search type failed', '');\n        await page.wait(0.8);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/ui.js#L57-L93","documentation":"Thrown by the qoder search (query) command when the required positional 'query' argument is missing or empty after trimming. The library validates arguments up front and raises ArgumentError('query', 'is required') rather than opening the search palette with a blank string. This is an input-validation error, not a UI failure.","triggerScenarios":"Calling the search command without the positional query argument; passing an empty string or whitespace-only string; passing a non-string value that String()s to empty; a wrapper script dropping the argument.","commonSituations":"Shell quoting mistakes that swallow the argument; CI scripts with empty variables interpolated into the command; users omitting the positional because they expected a --query flag.","solutions":["Pass the search text as the positional argument, e.g. qoder search \"error handling\".","Quote the argument so the shell doesn't split or drop it.","Check the upstream variable is non-empty before invoking the command."],"exampleFix":"// before\nQUERY=\"\"; qoder search $QUERY\n// after\nQUERY=\"error handling\"; [ -n \"$QUERY\" ] && qoder search \"$QUERY\"","handlingStrategy":"validation","validationCode":"const query = String(process.argv[2] || '').trim();\nif (!query) { console.error('usage: qoder search <query>'); process.exit(2); }","typeGuard":null,"tryCatchPattern":"try {\n  await search(page, query);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('query')) {\n    console.error('Pass a non-empty positional search text');\n  } else throw e;\n}","preventionTips":["Always quote the positional query in shell scripts.","Validate CLI variables are non-empty before invocation.","Remember query is positional, not a --query flag.","Trim whitespace-only inputs before calling."],"tags":["argument-validation","input-error","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}