jackwener/OpenCLI · error · CommandExecutionError

linux.do request failed: HTTP ${result.status ?? 'unknown'}

Error message

linux.do request failed: HTTP ${result.status ?? 'unknown'}

What it means

When the browser-mediated request to linux.do completes but result.ok is false (any status other than 401/403), fetchLinuxDoJson throws CommandExecutionError carrying result.error or a synthesized 'linux.do request failed: HTTP <status>' message. The status may be 'unknown' when the browser wrapper could not determine one. This is the library's generic non-2xx HTTP failure path for the Discourse API.

Source

Thrown at clis/linux-do/feed.js:106

        status: res.status,
        data,
        error: data === null ? 'Response is not valid JSON' : '',
      };
    } catch (error) {
      return {
        ok: false,
        error: error instanceof Error ? error.message : String(error),
      };
    }
  })()`);
    if (!result) {
        throw new CommandExecutionError('linux.do returned an empty browser response');
    }
    if (result.status === 401 || result.status === 403) {
        throw new AuthRequiredError('linux.do', 'linux.do requires an active signed-in browser session');
    }
    if (!result.ok) {
        throw new CommandExecutionError(result.error || `linux.do request failed: HTTP ${result.status ?? 'unknown'}`);
    }
    if (result.error) {
        throw new CommandExecutionError(result.error, 'Please verify your linux.do session is still valid');
    }
    return result.data;
}
function findMatchingTag(records, value) {
    const raw = value.trim();
    const normalized = normalizeLookupValue(value);
    return /^\d+$/.test(raw)
        ? records.find((item) => item.id === Number(raw)) ?? null
        : records.find((item) => normalizeLookupValue(item.name) === normalized)
            ?? records.find((item) => normalizeLookupValue(item.slug) === normalized)
            ?? null;
}
function findMatchingCategory(records, value) {
    const raw = value.trim();
    const normalized = normalizeLookupValue(value);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the HTTP status in the message: 404 means the tag/category doesn't exist — run `opencli linux-do tags` / `categories` to list valid ones
  2. For 429, wait and back off before retrying; reduce polling frequency
  3. For 5xx or unknown status, retry after a delay; check https://linux.do availability in a normal browser
  4. Clear stale metadata cache in ~/.opencli/cache/linux-do if ids no longer resolve

Example fix

// before (shell)
opencli linux-do feed --tag 99999   // linux.do request failed: HTTP 404
// after (shell)
opencli linux-do tags                 # confirm the tag id exists
opencli linux-do feed --tag 4
Defensive patterns

Strategy: retry

Validate before calling

function isTransientStatus(status) {
    return status == null || status === 429 || (status >= 500 && status <= 599);
}
// Only auto-retry transient statuses; surface 404 etc. immediately

Type guard

function isOkResult(result) {
    return Boolean(result) && typeof result === 'object' &&
        result.ok === true && !('error' in result && result.error);
}

Try / catch

import { CommandExecutionError } from '@jackwener/opencli/errors';
try {
    const topics = await data();
} catch (err) {
    if (err instanceof CommandExecutionError && /HTTP (429|5\d\d|unknown)/.test(err.message)) {
        await new Promise(r => setTimeout(r, 5000));
        // retry once, then surface
    } else {
        throw err;
    }
}

Prevention

When it happens

Trigger: Any fetchLinuxDoJson call (data, subData) where the site returns a non-ok, non-401/403 response: HTTP 404 for a mistyped/removed tag or category id, 429 rate limiting, 5xx server errors, network interception producing no status, or DNS/proxy failures surfaced through the browser.

Common situations: Passing a stale or invalid tag/category id from an old cache; hitting linux.do too frequently and getting rate-limited; transient linux.do or Cloudflare outages; corporate proxy interfering with the automated browser.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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