{"record":{"id":"2c68581c59aa3c94","repo":"jackwener/OpenCLI","slug":"weibo-delete-id-must-be-a-numeric-idstr-mblogid","errorCode":null,"errorMessage":"weibo delete: id must be a numeric idstr, mblogid, or Weibo post URL","messagePattern":"weibo delete: id must be a numeric idstr, mblogid, or Weibo post URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/weibo/delete.js","lineNumber":38,"sourceCode":"        if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n            throw new ArgumentError('weibo delete: URL must use http or https');\n        }\n        if (!WEIBO_HOST_RE.test(url.hostname)) {\n            throw new ArgumentError('weibo delete: URL must be a weibo.com or weibo.cn post URL');\n        }\n        const parts = url.pathname.split('/').filter(Boolean);\n        if (url.hostname.toLowerCase().endsWith('weibo.cn') && parts[0] === 'status') {\n            candidate = parts[1] ?? '';\n        } else {\n            candidate = parts.at(-1) ?? '';\n        }\n    } catch (error) {\n        if (error instanceof ArgumentError) throw error;\n    }\n\n    candidate = String(candidate ?? '').trim();\n    if (!POST_ID_RE.test(candidate)) {\n        throw new ArgumentError('weibo delete: id must be a numeric idstr, mblogid, or Weibo post URL');\n    }\n    return candidate;\n}\n\ncli({\n    site: 'weibo',\n    name: 'delete',\n    access: 'write',\n    description: 'Delete one of my Weibo posts by id',\n    domain: 'weibo.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        {\n            name: 'id',\n            required: true,\n            positional: true,\n            help: 'Post ID (numeric idstr or mblogid from URL / weibo me / weibo post output)',\n        },","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/delete.js#L20-L56","documentation":"After optional URL extraction (or if the input was not a URL), the final candidate id must match POST_ID_RE: 4-32 alphanumeric characters. This covers numeric idstr values and mblogid tokens. Anything else — mixed symbols, too short, too long, containing slashes/query leftovers — is rejected with ArgumentError.","triggerScenarios":"Passing the full post text, a username instead of a post id, an id with punctuation copied with trailing characters, a numeric id shorter than 4 chars, or a URL whose last path segment is empty or contains query strings.","commonSituations":"Copy-paste including '?from=...' fragments or brackets, using the display name instead of the post id, or truncating the mblogid when copying from terminal output.","solutions":["Copy the id exactly from `weibo me` or `weibo post` output (columns: id, mblogid)","Use the numeric idstr from the weibo.com URL path, or the 8-10 char mblogid segment — only [A-Za-z0-9], 4-32 chars","Strip any trailing '?', '/', or whitespace from the copied value"],"exampleFix":"// before\nweibo delete --id 'AbCdEfGhI?from=feed'\n// after\nweibo delete --id 'AbCdEfGhI'","handlingStrategy":"validation","validationCode":"const POST_ID_RE = /^[A-Za-z0-9]{4,32}$/;\nfunction isValidWeiboPostId(id) {\n  return typeof id === 'string' && POST_ID_RE.test(id.trim());\n}\nif (!isValidWeiboPostId(input)) throw new Error('id must be numeric idstr or mblogid');","typeGuard":"function isAlnumId(v) {\n  return typeof v === 'string' && /^[A-Za-z0-9]{4,32}$/.test(v.trim());\n}","tryCatchPattern":"try {\n  await cliDelete({ id: input });\n} catch (err) {\n  if (err instanceof ArgumentError && /numeric idstr, mblogid, or Weibo post URL/.test(err.message)) {\n    throw new Error('Strip query strings/punctuation; use id or mblogid from weibo post output');\n  } else throw err;\n}","preventionTips":["Copy ids verbatim from `weibo me`/`weibo post` output (id, mblogid columns)","Strip trailing '?', '/', and whitespace from copied values","Remember valid ids are 4-32 alphanumeric characters only","Validate with /^[A-Za-z0-9]{4,32}$/ in scripts before invoking"],"tags":["weibo","argument-validation","format-validation"],"backgroundTag":"invalid-id-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}