jackwener/OpenCLI · warning · EmptyResultError

rednote/user

Error message

rednote/user

What it means

The rednote user command throws EmptyResultError when, after all its pagination attempts, it collected zero notes for the requested user. The library throws it to signal 'the command ran fine but produced nothing', distinguishing an empty outcome from a network or usage failure. It is not a bug; the API simply returned no public notes for that profile.

Source

Thrown at clis/rednote/user.js:51

    func: async (page, kwargs) => {
        const userId = normalizeXhsUserId(String(kwargs.id));
        const limit = parseLimit(kwargs.limit);
        await page.goto(`https://${WEB_HOST}/user/profile/${userId}`);
        let snapshot = await page.evaluate(USER_SNAPSHOT_JS);
        let results = extractXhsUserNotes(snapshot ?? {}, userId, WEB_HOST);
        let previousCount = results.length;
        for (let i = 0; results.length < limit && i < 4; i += 1) {
            await page.autoScroll({ times: 1, delayMs: 1500 });
            await page.wait({ time: 1 });
            snapshot = await page.evaluate(USER_SNAPSHOT_JS);
            const nextResults = extractXhsUserNotes(snapshot ?? {}, userId, WEB_HOST);
            if (nextResults.length <= previousCount)
                break;
            results = nextResults;
            previousCount = nextResults.length;
        }
        if (results.length === 0) {
            throw new EmptyResultError('rednote/user', 'No public notes found for this rednote user.');
        }
        return results.slice(0, limit);
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the user identifier/username is correct by opening the profile in a browser.
  2. Check the target profile actually has public notes visible without login.
  3. Retry later or from a different network if rednote is blocking anonymous/region-blocked requests.
  4. Catch EmptyResultError in the caller and treat it as 'no data' rather than a fatal failure.

Example fix

// before
const notes = await rednoteUser({ user: userId });
// after
let notes;
try {
  notes = await rednoteUser({ user: userId });
} catch (err) {
  if (err instanceof EmptyResultError) notes = [];
  else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!userId || typeof userId !== 'string') throw new Error('rednote user id required before calling');

Type guard

function isValidUserId(v) { return typeof v === 'string' && v.trim().length > 0; }

Try / catch

try {
  const notes = await rednoteUser({ user: userId });
} catch (err) {
  if (err instanceof EmptyResultError) {
    // treat as zero results, not a failure
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling the rednote user command with a user whose note list is empty or inaccessible, so every pagination round yields no rows and `results.length === 0` at the final check in clis/rednote/user.js:51.

Common situations: Typo in the username/identifier so it resolves to a different account; the profile is private or banned; the account has no public notes; region/anti-scraping blocks return empty pages instead of errors.

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/cb14210321c40af3. Report an issue: GitHub.