{"record":{"id":"9a664e1f02174a08","repo":"jackwener/OpenCLI","slug":"not-found-9a664e","errorCode":"NOT_FOUND","errorMessage":"No articles found","messagePattern":"No articles found","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"warning","filePath":"clis/wikipedia/search.js","lineNumber":24,"sourceCode":"    name: 'search',\n    access: 'read',\n    description: 'Search Wikipedia articles',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'query', positional: true, required: true, help: 'Search keyword' },\n        { name: 'limit', type: 'int', default: 10, help: 'Max results' },\n        { name: 'lang', default: 'en', help: 'Language code (e.g. en, zh, ja)' },\n    ],\n    columns: ['title', 'snippet', 'url'],\n    func: async (args) => {\n        const limit = Math.max(1, Math.min(Number(args.limit), 50));\n        const lang = args.lang || 'en';\n        const q = encodeURIComponent(args.query);\n        const data = (await wikiFetch(lang, `/w/api.php?action=query&list=search&srsearch=${q}&srlimit=${limit}&format=json&utf8=1`));\n        const results = data?.query?.search;\n        if (!results?.length)\n            throw new CliError('NOT_FOUND', 'No articles found', 'Try a different keyword');\n        return results.map((r) => ({\n            title: r.title,\n            snippet: r.snippet.replace(/<[^>]+>/g, '').slice(0, 120),\n            url: `https://${lang}.wikipedia.org/wiki/${encodeURIComponent(r.title.replace(/ /g, '_'))}`,\n        }));\n    },\n});\n","sourceCodeStart":6,"sourceCodeEnd":32,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wikipedia/search.js#L6-L32","documentation":"CliError with code NOT_FOUND thrown by `opencli wikipedia search` when list=search returns an empty results array — no articles matched the search term on that language's Wikipedia. This is an expected outcome of a bad/over-specific query, not a crash.","triggerScenarios":"`opencli wikipedia search <query> --lang <lang>` where data.query.search is [] — the full-text search index has no matches for srsearch.","commonSituations":"Misspelled keywords, queries in a language different from the wiki edition, extremely specific multi-word phrases, searching for non-encyclopedic terms.","solutions":["Simplify the query to one or two broad keywords","Verify --lang matches the language your query is written in","Use wildcards or partial words (MediaWiki search supports prefix matching, e.g. javasc*)","Check spelling"],"exampleFix":"// before\nopencli wikipedia search \"the complete history of the transistor radio in japan\" --lang zh\n// after\nopencli wikipedia search \"transistor\" --lang en","handlingStrategy":"try-catch","validationCode":"if (!query.trim()) throw new Error('search query required');\nif (Number(limit) > 50) limit = 50;","typeGuard":"function hasSearchResults(d) {\n  return Array.isArray(d?.query?.search) && d.query.search.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await run('wikipedia search', [query, '--lang', lang]);\n} catch (e) {\n  if (e.code === 'NOT_FOUND') {\n    console.log(`No hits for \"${query}\" on ${lang}.wikipedia.org; try broader keywords or a matching language`);\n  } else throw e;\n}","preventionTips":["Use short, broad keyword queries","Match query language to the --lang edition","Check spelling before searching"],"tags":["not-found","search","wikipedia"],"backgroundTag":"no-search-results","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}