{"record":{"id":"8e7a7615ef506dc6","repo":"jackwener/OpenCLI","slug":"jike-search-query-cannot-be-empty","errorCode":null,"errorMessage":"Jike search query cannot be empty","messagePattern":"Jike search query cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/jike/search.js","lineNumber":87,"sourceCode":"    throw new CommandExecutionError(`Jike search pagination exceeded ${MAX_PAGES} pages before satisfying --limit`);\n}\n\ncli({\n    site: 'jike',\n    name: 'search',\n    access: 'read',\n    description: '搜索即刻帖子',\n    domain: 'web.okjike.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'query', type: 'string', required: true, positional: true, help: '即刻搜索关键词' },\n        { name: 'limit', type: 'int', default: DEFAULT_LIMIT },\n    ],\n    columns: ['id', 'author', 'content', 'likes', 'comments', 'time', 'url'],\n    func: async (page, kwargs) => {\n        const keyword = String(kwargs.query || '').trim();\n        if (!keyword) throw new ArgumentError('Jike search query cannot be empty');\n        const limit = normalizeJikeLimit(kwargs.limit, DEFAULT_LIMIT);\n        await page.goto(`https://web.okjike.com/search?q=${encodeURIComponent(keyword)}`);\n        await requireJikeIdentity(page);\n        return searchPosts(page, keyword, limit);\n    },\n});\n","sourceCodeStart":69,"sourceCodeEnd":94,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jike/search.js#L69-L94","documentation":"The jike search CLI trims the required positional query argument and throws ArgumentError if the result is an empty string, because the Jike search API cannot be meaningfully called without keywords. This is an input validation error raised before any network activity.","triggerScenarios":"Running the command with an empty string query, a whitespace-only query ('   '), or quoting mistakes where the positional arg binds to nothing (kwargs.query undefined -> String(undefined||'') === '').","commonSituations":"Shell quoting errors (empty '' argument); variables interpolating to empty values in scripts; trailing whitespace the user assumes is valid; forgetting the positional argument in a non-interactive pipeline.","solutions":["Pass a non-empty keyword: opencli jike search \"your query\".","Trim-check your script variable before invoking the command.","If the empty value comes from a config/env variable, fix that source value."],"exampleFix":"// before\nconst keyword = String(kwargs.query || '').trim();\nif (!keyword) throw new ArgumentError('Jike search query cannot be empty');\n// after: caller validates first\nconst q = (process.argv[2] || '').trim();\nif (!q) { console.error('usage: jike-search <query>'); process.exit(1); }\nawait runCli(['jike', 'search', q]);","handlingStrategy":"validation","validationCode":"const q = String(rawQuery ?? '').trim();\nif (!q) { console.error('jike search: query cannot be empty'); process.exit(2); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always trim and check the query before invoking the CLI.","Quote positional args in shell scripts to avoid empty binding.","Fail fast in wrappers when the query variable is empty."],"tags":["argument-validation","cli","input"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}