jackwener/OpenCLI · error · EmptyResultError

${result.detail}

Error message

${result.detail}

What it means

EmptyResultError thrown when the in-browser fetch of /r/<name>/about.json reports the subreddit is missing, banned, private, quarantined, or returns 401/403/404. The library converts these Reddit responses into a typed 'empty result' so the CLI output table never shows a silent placeholder row.

Source

Thrown at clis/reddit/subreddit-info.js:77

        // not found / not accessible" by the absence of data.display_name.
        if (j?.error) {
          if (j.error === 404 || j.reason === 'banned' || j.reason === 'private' || j.reason === 'quarantined') {
            return { kind: 'missing', detail: 'Subreddit r/' + sub + ' is ' + (j.reason || 'unavailable') + '.' };
          }
          return { kind: 'http', httpStatus: j.error, where: '/r/' + sub + '/about.json (' + (j.reason || 'error') + ')' };
        }
        const info = j?.data;
        if (!info || !info.display_name) {
          return { kind: 'malformed', detail: 'Reddit returned malformed subreddit info for r/' + sub + ' (missing data.display_name).' };
        }
        return { kind: 'ok', info };
      } catch (e) {
        return { kind: 'exception', detail: String(e && e.message || e) };
      }
    })()`);

        if (result?.kind === 'missing') {
            throw new EmptyResultError(result.detail);
        }
        if (result?.kind === 'http') {
            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);
        }
        if (result?.kind === 'malformed') {
            throw new CommandExecutionError(result.detail);
        }
        if (result?.kind === 'exception') {
            throw new CommandExecutionError(`subreddit-info failed: ${result.detail}`);
        }
        if (result?.kind !== 'ok') {
            throw new CommandExecutionError(`Unexpected result from reddit subreddit-info: ${JSON.stringify(result)}`);
        }

        const s = result.info;
        const created = s.created_utc
            ? new Date(s.created_utc * 1000).toISOString().split('T')[0]
            : null;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the subreddit exists by visiting https://www.reddit.com/r/<name> in a browser while logged in
  2. Re-check spelling; the name must be 3-21 chars, letters/digits/underscore (an r/ prefix is stripped automatically)
  3. If the sub is quarantined, open it once in the browser and click 'Continue' so the session cookie grants access
  4. If private, request access from moderators or use an account that is a member
  5. Log into reddit.com in the CLI's browser session if a 401/403 indicates auth is missing

Example fix

// before (fails)
reddit subreddit-info example-sub-that-was-banned
// after
reddit subreddit-info python
Defensive patterns

Strategy: try-catch

Validate before calling

const SUBREDDIT_RE = /^[A-Za-z][A-Za-z0-9_]{2,20}$/;
const name = raw.replace(/^\/r\//,'').replace(/^r\//,'').trim();
if (!SUBREDDIT_RE.test(name)) throw new Error(`invalid subreddit name: ${raw}`);

Type guard

function isEmptyResultErr(e){ return e && e.name === 'EmptyResultError'; }

Try / catch

try { await cli.redditSubredditInfo(name); }
catch (e) { if (e.name === 'EmptyResultError') { console.warn(`r/${name} unavailable: ${e.message}`); return null; } throw e; }

Prevention

When it happens

Trigger: Running `reddit subreddit-info <name>` where the subreddit does not exist, was banned, is private/quarantined, or Reddit's API returns 401/403 for that name (e.g. quarantined sub not opted into).

Common situations: Typos in subreddit names, subreddits banned or made private since last use, accessing quarantined subs without an opt-in cookie, region-blocked subs, deleted/rename of the subreddit.

Related errors


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