jackwener/OpenCLI · error · ArgumentError

Refusing to post: pass --execute to actually publish this co

Error message

Refusing to post: pass --execute to actually publish this comment

What it means

Posting a comment is a public, hard-to-retract action, so the library implements a write guard: it refuses to post unless --execute is explicitly passed, throwing ArgumentError with this instruction message.

Source

Thrown at clis/bilibili/comment.js:41

    domain: 'www.bilibili.com',
    strategy: Strategy.COOKIE,
    args: [
        { name: 'bvid', required: true, positional: true, help: 'Video BV ID / URL / b23.tv short link' },
        { name: 'message', required: true, positional: true, help: 'Comment text. Any @username in it is resolved to a real mention' },
        { name: 'parent', type: 'int', help: 'top-level/root rpid to reply under (omit for a top-level comment)' },
        { name: 'execute', type: 'boolean', help: 'Actually post the comment. Without it the command refuses to write.' },
    ],
    columns: ['rpid', 'bvid', 'oid', 'message', 'url'],
    func: async (page, kwargs) => {
        if (!page) {
            throw new CommandExecutionError('Browser session required for bilibili comment');
        }
        const message = String(kwargs.message ?? '').trim();
        if (!message)
            throw new ArgumentError('bilibili comment message cannot be empty');
        // Write guard: posting is public and irreversible-ish, so require an explicit opt-in.
        if (!kwargs.execute)
            throw new ArgumentError('Refusing to post: pass --execute to actually publish this comment');
        const parent = kwargs.parent != null ? readPositiveInteger(kwargs.parent, 'parent') : null;
        let bvid;
        try {
            bvid = await resolveBvid(kwargs.bvid);
        }
        catch (error) {
            throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${String(kwargs.bvid ?? '')}`, error instanceof Error ? error.message : String(error));
        }
        // Resolve bvid → aid (the reply API addresses videos by aid, as `oid`)
        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });
        const viewData = requireOkPayload(view, 'view');
        const oid = viewData?.aid;
        if (!oid)
            throw new CommandExecutionError(`Cannot resolve aid for bvid: ${bvid}`);
        // Resolve @username mentions to uids. Bilibili only turns "@name" into a real
        // mention — one that notifies the mentioned user — when the request carries
        // at_name_to_mid; a plain-text "@name" is otherwise inert and notifies nobody.
        /** @type {Record<string, number>} */

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Add --execute to actually publish the comment
  2. Keep running without --execute intentionally as a dry-run
  3. Add --execute to the pipeline's flag list for the live step
  4. Alias/wrap the command with --execute if you always intend to post

Example fix

// before
cli bilibili comment --bvid BV1xx --message "hello"
// after
cli bilibili comment --bvid BV1xx --message "hello" --execute
Defensive patterns

Strategy: validation

Validate before calling

if (!executeFlag) throw new Error('Dry run: add --execute to actually publish the comment');

Try / catch

try { await commentCmd(); } catch (e) { if (String(e.message).includes('--execute')) { console.error('Re-run with --execute to publish'); } else throw e; }

Prevention

When it happens

Trigger: Running the comment command with --message and a valid session but without --execute; automation doing a dry-run forgetting the flag on the real run.

Common situations: Testing the command expecting a dry run but then being surprised; pipelines that build flags dynamically dropping --execute; users unaware of the opt-in requirement.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/e15184443bfeaa15. Report an issue: GitHub.