{"record":{"id":"ebe4b2fe94794dae","repo":"jackwener/OpenCLI","slug":"query-cannot-be-empty","errorCode":null,"errorMessage":"query cannot be empty","messagePattern":"query cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/coupang/search.js","lineNumber":418,"sourceCode":"cli({\n    site: 'coupang',\n    name: 'search',\n    access: 'read',\n    description: 'Search Coupang products with logged-in browser session',\n    domain: 'www.coupang.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'query', required: true, positional: true, help: 'Search keyword' },\n        { name: 'page', type: 'int', default: 1, help: 'Search result page number' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max results (max 50)' },\n        { name: 'filter', required: false, help: 'Optional search filter (currently supports: rocket)' },\n    ],\n    columns: ['rank', 'product_id', 'title', 'price', 'unit_price', 'rating', 'review_count', 'rocket', 'delivery_type', 'delivery_promise', 'url'],\n    func: async (page, kwargs) => {\n        const query = String(kwargs.query || '').trim();\n        if (!query) {\n            throw new ArgumentError('query cannot be empty');\n        }\n        const pageNumber = parsePageArg(kwargs.page, 1);\n        const limit = parseLimitArg(kwargs.limit, 20, 50);\n        const filter = String(kwargs.filter || '').trim().toLowerCase();\n        if (filter && filter !== 'rocket') {\n            throw new ArgumentError(`Unsupported --filter \"${filter}\" (supported: rocket)`);\n        }\n        const initialPage = filter ? 1 : pageNumber;\n        const url = `https://www.coupang.com/np/search?q=${encodeURIComponent(query)}&channel=user&page=${initialPage}`;\n        await page.goto(url).catch((error) => {\n            throw new CommandExecutionError(`coupang search navigation failed: ${error?.message || error}`);\n        });\n        if (filter) {\n            const filterResult = await page.evaluate(buildApplyFilterEvaluate(filter)).catch((error) => {\n                throw new CommandExecutionError(`coupang search filter evaluation failed: ${error?.message || error}`);\n            });\n            if (!filterResult?.ok) {\n                throw new EmptyResultError('coupang search', `Filter \"${filter}\" was not available on the current page; try without --filter or wait for Coupang to render the filter bar.`);","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coupang/search.js#L400-L436","documentation":"ArgumentError (exit code 2, ARGUMENT / usage error) thrown by the coupang search command when the required query argument is missing, empty, or whitespace-only after trimming. The command refuses to build a search URL without a query.","triggerScenarios":"`opencli coupang search` with no query, an empty string, or only whitespace: e.g. `opencli coupang search \"\"` or omitting the positional/query kwarg entirely.","commonSituations":"Shell variable holding the query is empty/unset (e.g. $QUERY interpolated to nothing); quoting mistake causing the arg to be swallowed; scripting with a value that trims to nothing; forgetting the --query/positional form of the argument.","solutions":["Pass a non-empty query: opencli coupang search \"wireless keyboard\".","Check that the shell variable feeding the argument is set and non-blank.","Quote the query so spaces/special characters don't split or drop arguments.","Print/verify kwargs in your wrapper script before invoking the command."],"exampleFix":"// before\nopencli coupang search \"$QUERY\"   # QUERY is empty\n// after\n[ -n \"$QUERY\" ] && opencli coupang search \"$QUERY\"","handlingStrategy":"validation","validationCode":"function validateSearchQuery(query) {\n  const q = String(query ?? '').trim();\n  if (!q) throw new Error('query cannot be empty');\n  return q;\n}\n// usage: run('coupang search', { query: validateSearchQuery(userInput) })","typeGuard":"function hasQuery(kwargs) { return typeof kwargs?.query === 'string' && kwargs.query.trim().length > 0; }","tryCatchPattern":"try {\n  return await run('coupang search', { query });\n} catch (err) {\n  if (err?.code === 'ARGUMENT' && /query cannot be empty/.test(err.message)) {\n    console.error('Provide a non-empty search query, e.g. opencli coupang search \"keyboard\"');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Trim and check the query before invoking, especially when it comes from a shell variable.","Quote queries with spaces in the shell.","Use \"${VAR:?msg}\" in bash to fail fast on unset/empty variables.","Validate user input in wrapper scripts before calling the CLI."],"tags":["argument","validation","usage","coupang"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}