jackwener/OpenCLI · warning · EmptyResultError

No ${emptyLabel} notes found. Ensure you are logged in and t

Error message

No ${emptyLabel} notes found. Ensure you are logged in and this profile tab is visible.

What it means

fetchXhsCollectionNotes throws EmptyResultError when neither the API path nor the DOM fallback produced any notes. The library treats an empty collection as an operational problem (login state or page visibility) rather than a valid result.

Source

Thrown at clis/xiaohongshu/collection-helpers.js:277

    for (let i = 0; notes.length < limit && i < 4; i += 1) {
        await page.autoScroll({ times: 1, delayMs: 1500 });
        await page.wait(1);
        await assertOnCollectionProfile(page, userId);
        const nextNotes = await accumulateInterceptedNotes(page, capturedRequests, userId);
        if (nextNotes.length > previousCount) {
            notes = nextNotes;
            previousCount = nextNotes.length;
            continue;
        }
        break;
    }
    if (notes.length === 0) {
        const domNotes = await extractNotesFromDom(page);
        if (domNotes.length > 0)
            notes = domNotes;
    }
    if (notes.length === 0) {
        throw new EmptyResultError('xiaohongshu collection', `No ${emptyLabel} notes found. Ensure you are logged in and this profile tab is visible.`);
    }
    return notes.slice(0, limit).map((item, index) => ({
        rank: index + 1,
        ...item,
    }));
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the browser context is logged into XHS and can see the collection tab manually.
  2. Open the target profile tab URL in the page and verify notes render before running the command.
  3. Try another profile/own account - other users' liked tabs are often hidden.
  4. Increase wait times or scroll to trigger lazy-loaded notes before extraction.

Example fix

// before
try { notes = await fetchXhsCollectionNotes(page, opts); }
catch (e) { /* EmptyResultError */ }
// after
try { notes = await fetchXhsCollectionNotes(page, opts); }
catch (e) {
  if (e instanceof EmptyResultError) {
    await ensureLogin(page);
    await page.goto(tabUrl, { waitUntil: 'networkidle' });
    notes = await fetchXhsCollectionNotes(page, opts);
  } else throw e;
}
Defensive patterns

Strategy: fallback

Validate before calling

const visible = await page.locator('.note-item, [class*="note"]').count();
if (visible === 0) console.warn('No notes rendered on this tab - check login/tab visibility');

Type guard

function looksEmptyResult(e) {
  return e instanceof EmptyResultError || /No .* notes found/.test(String(e?.message));
}

Try / catch

try {
  notes = await fetchXhsCollectionNotes(page, opts);
} catch (e) {
  if (e instanceof EmptyResultError) {
    console.warn('Skipping tab:', opts.tab, '-', e.message);
    notes = [];
  } else throw e;
}

Prevention

When it happens

Trigger: API-fetched notes array is empty AND extractNotesFromDom also returns zero rows for the requested profile tab (e.g. liked/collected notes).

Common situations: User session not logged in, XHS hides liked/collection tabs for privacy, wrong tab/URL passed in emptyLabel context, or anti-bot rendering blocked the grid.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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