jackwener/OpenCLI · error · EmptyResultError

weibo delete

Error message

weibo delete

What it means

clis/weibo/delete.js:155 throws EmptyResultError('weibo delete', ...) when the delete script reports error==='not_found': the post id was syntactically valid but Weibo returned no matching mblog for the logged-in account. The library uses this to distinguish 'nothing to delete' from transient HTTP or auth failures.

Source

Thrown at clis/weibo/delete.js:155

          return { ok: false, error: 'verify_malformed', msg: 'verify returned non-JSON response', id: idstr };
        }
        if (!verifyBody || typeof verifyBody !== 'object') {
          return { ok: false, error: 'verify_malformed', msg: 'verify returned malformed response', id: idstr };
        }
        if (String(verifyBody.idstr || '') === idstr) {
          return { ok: false, error: 'still_exists', id: idstr, mblogid: verifyBody.mblogid || mblogid };
        }
        if (!verifyBody.idstr || verifyBody.ok === 0) {
          return { ok: true, id: idstr, mblogid };
        }
        return { ok: false, error: 'verify_mismatch', msg: 'verify returned a different post id', id: idstr };
      })()
    `)), 'weibo delete');
        if (result.error === 'auth') {
            throw new AuthRequiredError('weibo.com', 'Cookie 已过期!请在当前 Chrome 浏览器中重新登录 Weibo。');
        }
        if (result.error === 'not_found') {
            throw new EmptyResultError('weibo delete', `Post not found for id "${String(result.input ?? raw)}". Verify the post still exists and belongs to the logged-in account.`);
        }
        if (result.error === 'show_http' || result.error === 'destroy_http' || result.error === 'verify_http') {
            throw new CommandExecutionError(`weibo delete: HTTP ${result.status}`);
        }
        if (result.error === 'api' || result.error === 'verify_malformed' || result.error === 'verify_mismatch' || result.error === 'still_exists') {
            throw new CommandExecutionError(`weibo delete: ${String(result.msg ?? result.error)}`);
        }
        if (!result.ok) {
            throw new CommandExecutionError('weibo delete returned an unexpected response');
        }
        return [{ status: 'deleted', id: String(result.id ?? ''), mblogid: String(result.mblogid ?? '') }];
    },
});

export const __test__ = {
    normalizePostId,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the post still exists by opening its URL in Chrome while logged in
  2. Ensure the post belongs to the currently logged-in account — you can only delete your own posts
  3. Re-copy the id or post URL; for weibo.cn URLs verify the /status/<id> segment is the mblogid
  4. Treat a repeat not_found as 'already deleted' and skip rather than retry

Example fix

// before
await cli.run('weibo delete', { id: alreadyDeletedId });
// after: guard against already-deleted
try {
  await cli.run('weibo delete', { id });
} catch (e) {
  if (e instanceof EmptyResultError) return { status: 'already-deleted', id };
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

function isValidPostId(id) { const s = String(id ?? '').trim(); return /^[A-Za-z0-9]{4,32}$/.test(s) || /^https?:\/\/(www\.)?weibo\.(com|cn)\//.test(s); }
if (!isValidPostId(id)) throw new Error('bad weibo post id/url: ' + id);

Type guard

function isEmptyResultError(e) { return e instanceof Error && e.name === 'EmptyResultError'; }

Try / catch

try {
  await cli.run('weibo delete', { id });
} catch (e) {
  if (isEmptyResultError(e)) return { status: 'not-found-or-deleted', id };
  throw e;
}

Prevention

When it happens

Trigger: Calling `weibo delete <id|url>` where the id/mblogid does not resolve to an existing post: post already deleted, post belongs to another account, malformed-but-passing id, or a weibo.cn-style URL whose extracted id is wrong.

Common situations: Deleting the same post twice (second call hits not_found); id copied from a repost instead of the original; typo in mblogid; post removed by Weibo moderation or by the author from another device.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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