{"record":{"id":"90dde38ea62d1895","repo":"jackwener/OpenCLI","slug":"invalid-argument-90dde3","errorCode":"INVALID_ARGUMENT","errorMessage":"Keyword is required","messagePattern":"Keyword is required","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/gitee/search.js","lineNumber":80,"sourceCode":"    }\n}\ncli({\n    site: 'gitee',\n    name: 'search',\n    access: 'read',\n    description: 'Search repositories on Gitee',\n    domain: 'gitee.com',\n    strategy: Strategy.PUBLIC,\n    browser: true,\n    args: [\n        { name: 'keyword', positional: true, required: true, help: 'Search keyword' },\n        { name: 'limit', type: 'int', default: 10, help: 'Number of results (max 50)' },\n    ],\n    columns: ['rank', 'name', 'language', 'stars', 'description', 'url'],\n    func: async (page, args) => {\n        const keyword = String(args.keyword ?? '').trim();\n        if (!keyword) {\n            throw new CliError('INVALID_ARGUMENT', 'Keyword is required', 'Provide a search keyword');\n        }\n        const limit = clampLimit(args.limit);\n        const encodedKeyword = encodeURIComponent(keyword);\n        const searchUrl = `${GITEE_SEARCH_URL}?q=${encodedKeyword}&type=repository`;\n        const fetchSize = Math.max(10, limit);\n        const apiUrl = new URL(GITEE_SEARCH_API);\n        apiUrl.searchParams.set('q', keyword);\n        apiUrl.searchParams.set('from', '0');\n        apiUrl.searchParams.set('size', String(fetchSize));\n        await page.goto(searchUrl);\n        await page.wait(2);\n        const response = await fetch(apiUrl.toString(), {\n            headers: {\n                Accept: 'application/json',\n                'User-Agent': 'Mozilla/5.0',\n                Referer: searchUrl,\n            },\n        });","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gitee/search.js#L62-L98","documentation":"CliError with code INVALID_ARGUMENT thrown when the gitee search command receives no usable keyword. args.keyword is coerced to string and trimmed; if the result is empty, the library throws before making any network request, with hint 'Provide a search keyword'.","triggerScenarios":"Calling `opencli gitee search` (or the JS func) with keyword missing, an empty string, or a whitespace-only value like ' ' or args.keyword being undefined/null.","commonSituations":"Forgetting the positional/keyword argument in a shell script; passing an unquoted empty variable ('$KEYWORD' expanding to ''); piping pipelines where an upstream step produced an empty value; typos in the flag name so args.keyword is undefined.","solutions":["Pass a non-empty keyword, e.g. `opencli gitee search --keyword redis`","Quote shell variables and check they are non-empty before invoking: [ -n \"$KEYWORD\" ] || exit 1","Check flag spelling so args.keyword is actually populated (keyword vs query/q)","Handle the INVALID_ARGUMENT code in your wrapper to print usage"],"exampleFix":"// before\nopencli gitee search --keyword \"\"   # Keyword is required\n// after\nopencli gitee search --keyword \"redis cache\" --limit 10","handlingStrategy":"validation","validationCode":"const keyword = String(process.argv[2] ?? '').trim();\nif (!keyword) {\n  console.error('Usage: opencli gitee search <keyword>');\n  process.exit(1);\n}","typeGuard":"function hasKeyword(a) {\n  return typeof a === 'string' && a.trim().length > 0;\n}","tryCatchPattern":"try {\n  await giteeSearch(keyword);\n} catch (e) {\n  if (e.code === 'INVALID_ARGUMENT') {\n    console.error('Keyword is required. Usage: opencli gitee search <keyword>');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always pass a quoted, non-empty keyword argument","Validate/trim inputs in wrapper scripts before calling the CLI","Use consistent flag names (keyword) to avoid undefined args","Fail fast with usage output when required args are absent"],"tags":["validation","cli-arguments","gitee","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}