{"record":{"id":"741cb4c80b4b47be","repo":"jackwener/OpenCLI","slug":"who","errorCode":null,"errorMessage":"who 不能为空","messagePattern":"who 不能为空","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/1point3acres/user.js","lineNumber":29,"sourceCode":"\ncli({\n    site: '1point3acres',\n    name: 'user',\n    access: 'read',\n    description: '一亩三分地 用户空间（用户组 / 积分 / 大米 / 帖子数 等）',\n    domain: 'www.1point3acres.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'who', required: true, positional: true, help: '用户名或 uid（纯数字按 uid 查，否则按用户名）' },\n    ],\n    columns: [\n        'uid', 'username', 'group', 'credits', 'rice',\n        'posts', 'threads', 'digests', 'registerTime', 'lastAccess', 'profileUrl',\n    ],\n    func: async (args) => {\n        const who = String(args.who || '').trim();\n        if (!who) throw new ArgumentError('who 不能为空', '传用户名或数字 uid');\n        const url = /^\\d+$/.test(who)\n            ? `${BASE}/space-uid-${who}.html`\n            : `${BASE}/space-username-${encodeURIComponent(who)}.html`;\n\n        const html = await fetchHtml(url);\n        if (/<title>提示信息/.test(html) && /(没有找到|不存在)/.test(html)) {\n            throw new EmptyResultError('1point3acres user', `用户 \"${who}\" 不存在`);\n        }\n\n        const pick = (re) => {\n            const m = html.match(re);\n            return m ? decodeEntities(m[1].trim()) : '';\n        };\n        // <li>KEY: VAL</li>   — tolerant of optional <span>, colons fullwidth/半角, 颗/根/粒 suffixes.\n        const pickLi = (label) => {\n            const re = new RegExp(`<li>\\\\s*${label}[：:\\\\s]*(?:<[^>]+>)?\\\\s*([^<]+?)\\\\s*(?:<|$)`);\n            const m = html.match(re);\n            return m ? decodeEntities(m[1].trim()) : '';","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/1point3acres/user.js#L11-L47","documentation":"ArgumentError thrown by the 1point3acres user command when the `who` argument is missing or an empty/whitespace string. `who` accepts either a numeric uid or a username and is required to build the space profile URL, so the CLI fails fast with a hint (传用户名或数字 uid) telling the caller to supply one.","triggerScenarios":"Calling the user command without `who`, with an empty string, or with a value that trims to nothing (e.g. who: '   ').","commonSituations":"Forgot to pass the argument in a script; a variable upstream that resolved to '' or undefined; shell variable unquoted/empty in a CLI pipeline.","solutions":["Provide `who` as either a numeric uid (e.g. '363088') or a username string","Trim the value before calling if it comes from user input or env","Add an upstream check: if (!who) prompt for the username instead of calling","Note usernames are passed through encodeURIComponent — no need to pre-encode, but the raw value must be non-empty"],"exampleFix":"// before\nuser({ who: process.env.TARGET })  // TARGET unset → ArgumentError\n// after\nif (!process.env.TARGET) throw new Error('TARGET must be a username or uid');\nuser({ who: process.env.TARGET.trim() })","handlingStrategy":"validation","validationCode":"const who = String(input ?? '').trim();\nif (!who) throw new Error('who is required: a username or numeric uid');","typeGuard":"const hasWho = (v) => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  await user({ who });\n} catch (e) {\n  if (e instanceof ArgumentError) {\n    console.error('Pass who as a username or numeric uid, e.g. user({ who: \"jason\" }) or user({ who: \"363088\" })');\n  } else throw e;\n}","preventionTips":["Validate/trim `who` at the CLI/UI boundary before invoking","Guard upstream variables that may be undefined","Prefer numeric uid when the username may contain special characters"],"tags":["argument-validation","missing-argument","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}