jackwener/OpenCLI · error · ArgumentError
weibo publish text cannot be empty
Error message
weibo publish text cannot be empty
What it means
validateText rejects publish requests whose `text` option is missing, empty, or only whitespace. Weibo does not accept an empty post body, so the CLI fails fast with an ArgumentError before touching the browser.
Solutions
- Pass non-empty text via --text "your message"
- Check that any variable/file feeding the text is non-empty before invoking
- If posting images only is intended, note this CLI still requires non-empty text
Example fix
// before
weibo publish --text "$MSG"
// after
[ -n "$MSG" ] || { echo 'MSG is empty'; exit 1; }
weibo publish --text "$MSG" Defensive patterns
Strategy: validation
Validate before calling
const t = (text ?? '').trim();
if (!t) throw new Error('text is required and cannot be empty'); Type guard
function isValidText(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await cli.run(['weibo', 'publish', '--text', text]);
} catch (err) {
if (/text cannot be empty/.test(err.message)) {
console.error('Provide non-empty --text');
} else throw err;
} Prevention
- Always pass --text explicitly
- Validate shell variables are non-empty before interpolation
- Remember image-only posts are not supported by this CLI
When it happens
Trigger: Calling `weibo publish` without `--text`, with `--text ""` or `--text " "`, or when a shell variable holding the text expands to empty.
Common situations: CI scripts where the post body comes from an env var or file that is empty; forgetting the --text flag; quoting bugs that swallow the argument.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- weibo favorites must be a positive integer
- 正文不能超过 1000 字
- 正文不能超过 1000 字
- 标题不能超过 30 字
- archive search limit must be <= 100
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a184428ce52ebaf9.
Report an issue: GitHub.
Appendix: source
Thrown at clis/weibo/publish.js:46
const COMPOSE_TIMEOUT_MS = 10_000;
const SUBMIT_POLL_MS = 500;
const SUBMIT_TIMEOUT_MS = 20_000;
const SUPPORTED_EXTENSIONS = new Set(['.jpg', '.jpeg', '.png', '.gif', '.webp']);
// Weibo PC UI selectors. The CSS-module hash drifts on every frontend
// rebuild (#1602), so match on the stable placeholder text and keep the
// legacy hash as a last-resort fallback. Callers pick the LAST visible
// match because the compose modal renders on top of the home-feed strip.
const TEXTAREA_SELECTORS = [
'textarea[placeholder*="有什么新鲜事"]',
'textarea[placeholder*="新鲜事"]',
'textarea._input_13iqr_8',
];
const FILE_INPUT_SELECTOR = 'input[type="file"][class*="_file_"]';
function validateText(text) {
const t = String(text ?? '').trim();
if (!t) throw new ArgumentError('weibo publish text cannot be empty');
if (t.length > 2000) throw new ArgumentError('weibo publish text exceeds 2000 characters');
return t;
}
function validateImagePaths(raw) {
if (!raw) return [];
const paths = raw.split(',').map(s => s.trim()).filter(Boolean);
if (paths.length > MAX_IMAGES) {
throw new ArgumentError(`Too many images: ${paths.length} (max ${MAX_IMAGES})`);
}
return paths.map(p => {
const absPath = path.resolve(p);
const ext = path.extname(absPath).toLowerCase();
if (!SUPPORTED_EXTENSIONS.has(ext)) {
throw new ArgumentError(`Unsupported image format "${ext}". Supported: jpg, png, gif, webp`);
}
const stat = fs.statSync(absPath, { throwIfNoEntry: false });
if (!stat || !stat.isFile()) {View on GitHub (pinned to 49907e53dc)