{"record":{"id":"6c87d6f6c64d88ff","repo":"jackwener/OpenCLI","slug":"invalid-argument-6c87d6","errorCode":"INVALID_ARGUMENT","errorMessage":"Username is required","messagePattern":"Username is required","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/gitee/user.js","lineNumber":82,"sourceCode":"    }\n    return '';\n}\ncli({\n    site: 'gitee',\n    name: 'user',\n    access: 'read',\n    description: 'Show a Gitee user profile panel',\n    domain: 'gitee.com',\n    strategy: Strategy.PUBLIC,\n    browser: true,\n    args: [\n        { name: 'username', positional: true, required: true, help: 'Gitee username' },\n    ],\n    columns: ['field', 'value'],\n    func: async (page, args) => {\n        const username = sanitizeUsername(String(args.username ?? ''));\n        if (!username) {\n            throw new CliError('INVALID_ARGUMENT', 'Username is required', 'Use: opencli gitee user <username>');\n        }\n        const profileUrl = `${GITEE_BASE_URL}/${encodeURIComponent(username)}`;\n        await page.goto(profileUrl);\n        await page.wait(2);\n        const rawDomSnapshot = await page.evaluate(`\n      (() => {\n        const normalize = (value) => (value || '').replace(/\\\\s+/g, ' ').trim();\n        const extractCount = (value) => {\n          const text = normalize(value).replace(/,/g, '');\n          if (!text) return '';\n          const match = text.match(/\\\\d+(?:[.]\\\\d+)?(?:\\\\s*[kKmMwW\\\\u4E07])?/);\n          return match ? match[0].replace(/\\\\s+/g, '') : '';\n        };\n\n        const title = normalize(document.title || '');\n        const bodyText = normalize(document.body?.innerText || '');\n        const notFound = /404|页面不存在|资源不存在|page not found/i.test(title + ' ' + bodyText);\n        const blocked = /访问受限|没有访问权限|forbidden|denied/i.test(bodyText);","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gitee/user.js#L64-L100","documentation":"CliError with code INVALID_ARGUMENT thrown when the gitee user command receives no usable username. args.username is sanitized (trimmed/stripped); if empty, the command throws before navigating, with usage hint 'Use: opencli gitee user <username>'.","triggerScenarios":"Calling `opencli gitee user` without the required positional username, or passing only whitespace or characters that sanitize to an empty string (e.g. '/').","commonSituations":"Forgetting the positional argument in scripts; an upstream variable holding the username is empty; passing a full profile URL where only the handle is expected and the sanitizer strips it to nothing; quoting mistakes dropping the argument.","solutions":["Pass the username positionally: `opencli gitee user <username>`","Validate the argument is non-empty in your wrapper before invoking","Pass just the handle, not a full URL, if sanitization removes the prefix","Print usage (per the hint) when INVALID_ARGUMENT code is caught"],"exampleFix":"// before\nopencli gitee user \"\"   # Username is required\n// after\nopencli gitee user mindspore","handlingStrategy":"validation","validationCode":"const username = String(process.argv[2] ?? '').trim();\nif (!/^[A-Za-z0-9_-]+$/.test(username)) {\n  console.error('Usage: opencli gitee user <username>');\n  process.exit(1);\n}","typeGuard":"function hasUsername(a) {\n  return typeof a === 'string' && a.trim().length > 0;\n}","tryCatchPattern":"try {\n  await giteeUser(username);\n} catch (e) {\n  if (e.code === 'INVALID_ARGUMENT') {\n    console.error('Username is required. Use: opencli gitee user <username>');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always pass the positional username argument, quoted","Pass the login handle, not a full profile URL or email","Validate argument presence in wrapper scripts before invoking","Print usage text on empty/invalid usernames"],"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"}