{"record":{"id":"255d09886ca24f37","repo":"jackwener/OpenCLI","slug":"weibo-user-posts-id-cannot-be-empty","errorCode":null,"errorMessage":"weibo user-posts id cannot be empty","messagePattern":"weibo user-posts id cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/weibo/user-posts.js","lineNumber":15,"sourceCode":"/**\n * Weibo user-posts — list posts from a user within an optional date range.\n */\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\nimport { unwrapEvaluateResult } from './utils.js';\n\nconst MAX_LIMIT = 100;\nconst DEFAULT_LIMIT = 20;\nconst DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nfunction readRequiredId(raw) {\n    const value = String(raw ?? '').trim();\n    if (!value) {\n        throw new ArgumentError('weibo user-posts id cannot be empty');\n    }\n    return value;\n}\n\nfunction readLimit(raw) {\n    const value = raw === undefined || raw === null || raw === '' ? DEFAULT_LIMIT : Number(raw);\n    if (!Number.isInteger(value) || value < 1 || value > MAX_LIMIT) {\n        throw new ArgumentError(`weibo user-posts limit must be an integer between 1 and ${MAX_LIMIT}`);\n    }\n    return value;\n}\n\nfunction readDate(raw, name) {\n    if (raw === undefined || raw === null || raw === '') return null;\n    const value = String(raw).trim();\n    if (!DATE_RE.test(value)) {\n        throw new ArgumentError(`weibo user-posts ${name} must use YYYY-MM-DD`);\n    }","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/user-posts.js#L1-L33","documentation":"ArgumentError thrown by readRequiredId when the `id` argument to `weibo user-posts` is empty, whitespace-only, null, or undefined. The command requires a user id (or profile identifier) to know whose posts to fetch, and refuses to run with a blank value.","triggerScenarios":"Running `weibo user-posts \"\"` or `weibo user-posts` with no positional id, or passing a value that is only whitespace (String(raw ?? '').trim() yields '').","commonSituations":"Shell variable holding the id was unset (`weibo user-posts \"$UID_VAR\"` with empty var); scripting pipelines where an upstream extraction produced an empty string; forgetting the positional argument entirely.","solutions":["Pass a non-empty user id: `weibo user-posts <id>`","Verify the upstream variable actually contains the id before invoking (echo it or add a shell check)","Look up the correct id from the user's weibo.com profile URL"],"exampleFix":"// before\nweibo user-posts \"$WEIBO_ID\"\n// after\n[ -n \"${WEIBO_ID:-}\" ] || { echo 'WEIBO_ID is empty'; exit 1; }\nweibo user-posts \"$WEIBO_ID\"","handlingStrategy":"validation","validationCode":"const id = String(process.env.WEIBO_ID ?? '').trim();\nif (!id) {\n    throw new Error('weibo user-posts requires a non-empty id');\n}\nawait weiboUserPosts({ id });","typeGuard":"function hasRequiredId(raw) {\n    return typeof raw === 'string' && raw.trim().length > 0;\n}","tryCatchPattern":"try {\n    await weiboUserPosts({ id });\n} catch (err) {\n    if (err instanceof ArgumentError && String(err.message).includes('id cannot be empty')) {\n        console.error('Provide a Weibo user id, e.g. `weibo user-posts <id>`');\n    } else throw err;\n}","preventionTips":["Always trim and check id values sourced from env/config before invoking","Look up ids from the user's profile URL (weibo.com/u/<id>)","Fail fast in shell scripts with [ -n \"$ID\" ] before calling the CLI"],"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"}