jackwener/OpenCLI · error · CommandExecutionError

Reddit subscriptions row ${index + 1} was missing subreddit

Error message

Reddit subscriptions row ${index + 1} was missing subreddit identity.

What it means

CommandExecutionError thrown by mapSubredditRow when a subscription entry's data object exists but lacks one of the identity fields the library requires: id (t5_ fullname or t5 derivable), display_name, display_name_prefixed (or derivable), and a /r/-prefixed url. This guarantees every output row has a complete, unique subreddit identity.

Source

Thrown at clis/reddit/subscribed.js:43

function mapSubredditRow(entry, index) {
    const data = entry?.data;
    if (!data || typeof data !== 'object') {
        throw new CommandExecutionError(`Reddit subscriptions row ${index + 1} was missing data.`);
    }
    const fullname = typeof data.name === 'string' ? data.name : '';
    const id = fullname.startsWith('t5_')
        ? fullname
        : (entry?.kind === 't5' && typeof data.id === 'string' && data.id ? `t5_${data.id}` : '');
    const displayName = typeof data.display_name === 'string' && data.display_name
        ? data.display_name
        : '';
    const subreddit = typeof data.display_name_prefixed === 'string' && data.display_name_prefixed
        ? data.display_name_prefixed
        : (displayName ? `r/${displayName}` : '');
    const path = typeof data.url === 'string' && data.url.startsWith('/r/') ? data.url : '';
    if (!id || !displayName || !subreddit || !path) {
        throw new CommandExecutionError(`Reddit subscriptions row ${index + 1} was missing subreddit identity.`);
    }
    return {
        id,
        subreddit,
        title: typeof data.title === 'string' ? data.title : '',
        subscribers: typeof data.subscribers === 'number' ? data.subscribers : null,
        description: typeof data.public_description === 'string' ? data.public_description.slice(0, 200) : '',
        url: 'https://www.reddit.com' + path,
    };
}

cli({
    site: 'reddit',
    name: 'subscribed',
    description: 'List subreddits you are subscribed to',
    access: 'read',
    domain: 'reddit.com',
    strategy: Strategy.COOKIE,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry — if it is a transient partially-populated payload it may resolve
  2. Inspect the raw payload at /subreddits/mine/subscriptions.json?raw_json=1 while logged in to see which field is missing for the offending row
  3. Update the library to a version matching the current Reddit schema
  4. Lower --limit or run repeatedly to narrow which specific subscription produces the malformed row, then check that subreddit's status directly
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check payload shape yourself before mapping
const d = await page.evaluate(`fetch('/subreddits/mine/subscriptions.json?limit=1&raw_json=1',{credentials:'include'}).then(r=>r.json())`);
const c = d?.data?.children?.[0];
if (c && !(c.data?.name && c.data?.display_name && c.data?.url?.startsWith('/r/'))) console.warn('identity fields incomplete in payload');

Type guard

function hasSubredditIdentity(entry){
  const d = entry?.data;
  return !!d && typeof d === 'object'
    && typeof d.display_name === 'string' && d.display_name
    && typeof d.url === 'string' && d.url.startsWith('/r/')
    && (typeof d.name === 'string' && d.name.startsWith('t5_') || typeof d.id === 'string' && d.id);
}

Try / catch

try { const rows = await cli.redditSubscribed({ limit }); }
catch (e) {
  if (/was missing subreddit identity\.$/.test(e.message)) { console.warn('schema drift detected; update library'); return null; }
  throw e;
}

Prevention

When it happens

Trigger: A child entry in subscriptions.json whose data is present but missing/in the wrong type one of: name/id, display_name, display_name_prefixed, or url not starting with '/r/'. Typically Reddit schema drift or partially-populated rows for newly-created or hidden subs.

Common situations: Reddit API changes renaming/moving fields; brand-new subreddits with incomplete about payloads; cached or stale responses via proxies; non-standard entries in the mine/subscriptions listing.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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