jackwener/OpenCLI · warning · EmptyResultError

douyin stats ${awemeId}

Error message

douyin stats ${awemeId}

What it means

EmptyResultError (scope `douyin stats <awemeId>`) thrown when the matched creator item exists in the item/list response but its `metrics` field is missing, not an object, or an array. The work exists in the creator account, but the 26-field creator metrics payload wasn't returned.

Source

Thrown at clis/douyin/stats.js:63

        let cursor;

        for (let hop = 0; hop < MAX_HOPS; hop++) {
            const params = new URLSearchParams({
                count: String(PAGE_SIZE),
                order_by: '1',
                fields: 'metrics,review,visibility',
                need_cooperation: 'true',
                need_long_article: 'true',
            });
            if (cursor !== undefined)
                params.set('max_cursor', String(cursor));

            const response = await browserFetch(page, 'GET', `${ITEM_LIST_URL}?${params.toString()}`);
            const item = (response.items ?? []).find((candidate) => sameAwemeId(candidate?.id, awemeId));
            if (item) {
                const metrics = item.metrics;
                if (!metrics || typeof metrics !== 'object' || Array.isArray(metrics)) {
                    throw new EmptyResultError(`douyin stats ${awemeId}`, 'The work exists, but creator metrics are unavailable');
                }
                return Object.entries(metrics).map(([metric, value]) => ({ metric, value }));
            }

            const nextCursor = response.max_cursor;
            if (!response.has_more || nextCursor === undefined || nextCursor === null
                || (cursor !== undefined && String(nextCursor) === String(cursor))) {
                break;
            }
            cursor = nextCursor;
        }

        throw new EmptyResultError(`douyin stats ${awemeId}`, 'The work was not found in the logged-in creator account');
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify in creator.douyin.com that the work is published and its data panel shows metrics.
  2. Wait and retry if the work was just published (metrics compute asynchronously).
  3. Confirm the aweme_id belongs to the logged-in creator account's own works.
  4. Handle EmptyResultError gracefully and fall back to public/detail metrics if creator metrics are unavailable.

Example fix

// before
const rows = await run(['douyin', 'stats', awemeId]);
// after
try {
  const rows = await run(['douyin', 'stats', awemeId]);
} catch (e) {
  if (e.name === 'EmptyResultError' && /metrics are unavailable/.test(e.message ?? '')) {
    return fallbackPublicMetrics(awemeId); // detail endpoint
  }
  throw e;
}
Defensive patterns

Strategy: fallback

Type guard

function hasMetrics(item) {
  return item != null && typeof item.metrics === 'object' && item.metrics !== null && !Array.isArray(item.metrics);
}

Try / catch

try {
  rows = await run(['douyin', 'stats', awemeId]);
} catch (e) {
  if (e.name === 'EmptyResultError' && /creator metrics are unavailable/.test(e.message ?? '')) {
    return publicDetailMetrics(awemeId); // fallback source
  }
  throw e;
}

Prevention

When it happens

Trigger: The item/list API returns an item whose metrics key is null/absent — typically when the work is under review, deleted-but-cached, a non-video type slipping through, or the account lacks deep-metrics permission for that work.

Common situations: Querying a work still in review or recently published before metrics are computed; works outside the logged-in creator account surfaced via cooperation list; Douyin API field changes; non-video works (long articles) with empty metric sets.

Related errors


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