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 fetch reports result.ok === false without a session-specific cause, the library throws CommandExecutionError with the server error or an HTTP status summary. It is a catch-all for non-2xx responses that are not auth-related.

Source

Thrown at clis/linux-do/topic-content.js:116

      };
    } 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_DOMAIN, 'linux.do requires an active signed-in browser session');
    }
    if (result.error === 'Response is not valid JSON') {
        throw new AuthRequiredError(LINUX_DO_DOMAIN, '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;
}
cli({
    site: 'linux-do',
    name: 'topic-content',
    access: 'read',
    description: 'Get the main topic body as Markdown',
    domain: LINUX_DO_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    defaultFormat: 'plain',
    args: [
        { name: 'id', positional: true, type: 'int', required: true, help: 'Topic ID' },
    ],

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the topic ID is valid and the topic still exists in the web UI.
  2. Wait and retry with backoff if the status is 429 or 5xx.
  3. Slow down batch loops to stay under linux.do rate limits.
  4. Print/log result.status to identify the exact HTTP code.

Example fix

// before
for (const id of ids) {
  results.push(extractTopicContent(await fetchTopicPayload(page, id), id));
}
// after
for (const id of ids) {
  await sleep(1500); // respect rate limits
  try {
    results.push(extractTopicContent(await fetchTopicPayload(page, id), id));
  } catch (e) {
    console.error(`Topic ${id} failed: ${e.message}`);
  }
}
Defensive patterns

Strategy: retry

Validate before calling

if (!Number.isInteger(id) || id <= 0) {
  throw new Error('Refusing request: invalid topic id would 404');
}

Type guard

const isHttpError = (e) => /linux\.do request failed: HTTP/.test(e?.message ?? '');

Try / catch

try {
  return await fetchTopicPayload(page, id);
} catch (e) {
  if (isHttpError(e)) {
    const status = Number(e.message.match(/HTTP (\d+)/)?.[1] ?? 0);
    if (status === 429 || status >= 500) return retryWithBackoff(() => fetchTopicPayload(page, id));
  } else throw e;
}

Prevention

When it happens

Trigger: Any non-ok HTTP response from the topic endpoint that is not 401/403 and not the invalid-JSON case — e.g. 404 for a deleted topic, 429 rate-limit, 5xx server error — or a result.error string set by the fetch wrapper.

Common situations: Typo in the topic ID hitting a 404; linux.do rate limiting rapid CLI calls; temporary linux.do outage; topic removed while scripting a batch.

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