jackwener/OpenCLI · error · CommandExecutionError

Xiaoyuzhou history returned a missing ${label}

Error message

Xiaoyuzhou history returned a missing ${label}

What it means

This CommandExecutionError is thrown by optionalIsoTime when a required ISO-8601 timestamp (pubDate, with required: true) is absent (null/undefined). Distinguishing 'missing' from 'malformed', this specific message fires only when the value is null even though the library requires it; a present-but-unparseable value raises the sibling 'invalid' error instead.

Source

Thrown at clis/xiaoyuzhou/history.js:49

function requiredString(value, label) {
    if (typeof value !== 'string' || !value.trim()) {
        throw new CommandExecutionError(`Xiaoyuzhou history returned an invalid ${label}`);
    }
    return value.trim();
}

function optionalSeconds(value, label, { positive = false } = {}) {
    if (value === null) return null;
    if (!Number.isSafeInteger(value) || value < (positive ? 1 : 0)) {
        throw new CommandExecutionError(`Xiaoyuzhou history returned an invalid ${label}; expected seconds`);
    }
    return value;
}

function optionalIsoTime(value, label, { required = false } = {}) {
    if (value === null) {
        if (required) throw new CommandExecutionError(`Xiaoyuzhou history returned a missing ${label}`);
        return null;
    }
    if (typeof value !== 'string' || !value.includes('T') || !Number.isFinite(Date.parse(value))) {
        throw new CommandExecutionError(`Xiaoyuzhou history returned an invalid ${label}`);
    }
    return new Date(value).toISOString();
}

function parseHistoryPage(response) {
    if (!isRecord(response) || !isRecord(response.raw) || response.raw.data !== response.data) {
        throw new CommandExecutionError('Xiaoyuzhou history returned an unexpected response shape');
    }
    const payload = response?.data;
    let entries;
    let next;
    if (Array.isArray(payload)) {
        entries = payload;
        next = response.raw?.loadMoreKey;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update the library/CLI in case the field was renamed (e.g. pubDate -> publishedAt) and a newer version reads the new key.
  2. Inspect the raw episode object to confirm whether the field moved or is genuinely absent.
  3. Skip/sanitize rows missing pubDate before parsing if you only need their titles, as a stopgap patch.
  4. Retry with fresh authentication or after a delay — transient partial responses can omit fields.
  5. Report the payload shape to maintainers with the offending episode id.

Example fix

// before
{ "episode": { "eid": "...", "pubDate": null } }
// after (stopgap sanitize before parse)
if (entry.episode.pubDate == null) return null; // skip rows without pubDate
Defensive patterns

Strategy: validation

Validate before calling

function hasPubDate(entry) { return typeof entry?.episode?.pubDate === 'string' && entry.episode.pubDate.includes('T') && !Number.isNaN(Date.parse(entry.episode.pubDate)); }
const parseable = entries.filter(hasPubDate); // drop rows without a required pubDate

Type guard

const isIsoTimestamp = (v) => typeof v === 'string' && v.includes('T') && Number.isFinite(Date.parse(v));

Try / catch

try { const rows = await fetchHistory(); } catch (e) { if (e instanceof CommandExecutionError && e.message.includes('missing pubDate')) { console.error('Episode without pubDate — check for renamed field or unpublished episode'); } else throw e; }

Prevention

When it happens

Trigger: parseHistoryEpisode calls optionalIsoTime(episode.pubDate, ..., { required: true }); the error fires when episode.pubDate is null or undefined. optionalIsoTime is also called on row.playedAt in parseProgressRows but without required:true, so only pubDate triggers this exact message.

Common situations: API schema change renaming pubDate or moving it to a nested object; newly published episodes without a publish date yet in history; cached/proxied responses stripping fields; drafts or scheduled episodes leaking into history without a pubDate.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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