{"record":{"id":"e15184443bfeaa15","repo":"jackwener/OpenCLI","slug":"refusing-to-post-pass-execute-to-actually-publi","errorCode":null,"errorMessage":"Refusing to post: pass --execute to actually publish this comment","messagePattern":"Refusing to post: pass --execute to actually publish this comment","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/comment.js","lineNumber":41,"sourceCode":"    domain: 'www.bilibili.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'bvid', required: true, positional: true, help: 'Video BV ID / URL / b23.tv short link' },\n        { name: 'message', required: true, positional: true, help: 'Comment text. Any @username in it is resolved to a real mention' },\n        { name: 'parent', type: 'int', help: 'top-level/root rpid to reply under (omit for a top-level comment)' },\n        { name: 'execute', type: 'boolean', help: 'Actually post the comment. Without it the command refuses to write.' },\n    ],\n    columns: ['rpid', 'bvid', 'oid', 'message', 'url'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for bilibili comment');\n        }\n        const message = String(kwargs.message ?? '').trim();\n        if (!message)\n            throw new ArgumentError('bilibili comment message cannot be empty');\n        // Write guard: posting is public and irreversible-ish, so require an explicit opt-in.\n        if (!kwargs.execute)\n            throw new ArgumentError('Refusing to post: pass --execute to actually publish this comment');\n        const parent = kwargs.parent != null ? readPositiveInteger(kwargs.parent, 'parent') : null;\n        let bvid;\n        try {\n            bvid = await resolveBvid(kwargs.bvid);\n        }\n        catch (error) {\n            throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${String(kwargs.bvid ?? '')}`, error instanceof Error ? error.message : String(error));\n        }\n        // Resolve bvid → aid (the reply API addresses videos by aid, as `oid`)\n        const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });\n        const viewData = requireOkPayload(view, 'view');\n        const oid = viewData?.aid;\n        if (!oid)\n            throw new CommandExecutionError(`Cannot resolve aid for bvid: ${bvid}`);\n        // Resolve @username mentions to uids. Bilibili only turns \"@name\" into a real\n        // mention — one that notifies the mentioned user — when the request carries\n        // at_name_to_mid; a plain-text \"@name\" is otherwise inert and notifies nobody.\n        /** @type {Record<string, number>} */","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/comment.js#L23-L59","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add --execute to actually publish the comment","Keep running without --execute intentionally as a dry-run","Add --execute to the pipeline's flag list for the live step","Alias/wrap the command with --execute if you always intend to post"],"exampleFix":"// before\ncli bilibili comment --bvid BV1xx --message \"hello\"\n// after\ncli bilibili comment --bvid BV1xx --message \"hello\" --execute","handlingStrategy":"validation","validationCode":"if (!executeFlag) throw new Error('Dry run: add --execute to actually publish the comment');","typeGuard":null,"tryCatchPattern":"try { await commentCmd(); } catch (e) { if (String(e.message).includes('--execute')) { console.error('Re-run with --execute to publish'); } else throw e; }","preventionTips":["Treat runs without --execute as dry-runs intentionally","Include --execute explicitly in pipeline live steps","Never add --execute by default in shared wrappers without review"],"tags":["safety-guard","write-guard","cli"],"backgroundTag":"missing-required-flag","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}