jackwener/OpenCLI · error · CommandExecutionError

TikTok Studio item_list returned an unreadable response

Error message

TikTok Studio item_list returned an unreadable response

What it means

The in-page fetch script is supposed to always return an object describing the HTTP outcome. When page.evaluate resolves with null/undefined or a non-object (e.g. serialization stripped the value, or an unexpected return shape), the library throws this CommandExecutionError instead of crashing later on property access.

Source

Thrown at clis/tiktok/creator-videos.js:191

    return {
        video_id: videoId,
        title: String(item.desc ?? item.title ?? '').replace(/\s+/g, ' ').trim(),
        date: formatDate(item.post_time ?? item.create_time ?? item.schedule_time),
        views: normalizeNumber(item.play_count),
        likes: normalizeNumber(item.like_count),
        comments: normalizeNumber(item.comment_count),
        saves: normalizeNumber(item.favorite_count),
        shares: normalizeNumber(item.share_count),
        url,
    };
}

async function fetchCreatorVideosPage(page, cursor, size) {
    const result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size))).catch((error) => {
        throw new CommandExecutionError(`Failed to fetch TikTok Studio item_list: ${getErrorMessage(error)}`);
    });
    if (!result || typeof result !== 'object') {
        throw new CommandExecutionError('TikTok Studio item_list returned an unreadable response');
    }
    if (result.networkError) {
        throw new CommandExecutionError(`TikTok Studio item_list network failure: ${result.networkError}`);
    }
    if (result.status === 401 || result.status === 403) {
        throw new AuthRequiredError('www.tiktok.com', `TikTok Studio item_list requires login (HTTP ${result.status})`);
    }
    if (!result.ok) {
        const detail = result.parseError
            ? `invalid JSON (${result.parseError})`
            : `HTTP ${result.status || 0}${result.statusText ? ` ${result.statusText}` : ''}`;
        throw new CommandExecutionError(`TikTok Studio item_list failed: ${detail}`, result.text ? `Response preview: ${result.text}` : undefined);
    }
    const payload = unwrapPayload(result.data);
    assertApiSuccess(payload);
    return payload;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log the raw result from page.evaluate to see what the browser actually returned
  2. Verify you are on www.tiktok.com (Studio) and the page finished loading before evaluating
  3. Update this CLI library — TikTok DOM/API changes may need a patched fetch script
  4. If persistent, dump the page HTML/screenshot and report the TikTok response shape

Example fix

// before
const result = await page.evaluate(script);
if (!result || typeof result !== 'object') throw new Error('unreadable');
// after
const result = await page.evaluate(script);
console.debug('item_list raw result:', result);
if (!result || typeof result !== 'object') throw new Error('unreadable: ' + JSON.stringify(result));
Defensive patterns

Strategy: type-guard

Type guard

function isReadableItemResult(v) { return v !== null && typeof v === 'object'; }

Try / catch

try {
  rows = await listCreatorVideos(page, opts);
} catch (e) {
  if (/unreadable response/.test(e.message)) {
    console.error('item_list returned:', typeof result); // debug shape, then update library
  }
  throw e;
}

Prevention

When it happens

Trigger: result is null/undefined or typeof result !== 'object' after page.evaluate resolves — typically when the injected script returns undefined or the browser serializes the result to nothing.

Common situations: A TikTok frontend update replaced the global fetch override path, the evaluate script was truncated by a CSP/script error, or a newer browser returns undefined for blocked requests instead of the structured object.

Related errors


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