{"record":{"id":"2f466b001802e48a","repo":"jackwener/OpenCLI","slug":"linux-do-request-failed-http-result-status-2f466b","errorCode":null,"errorMessage":"linux.do request failed: HTTP ${result.status ?? 'unknown'}","messagePattern":"linux\\.do request failed: HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linux-do/topic-content.js","lineNumber":116,"sourceCode":"      };\n    } catch (error) {\n      return {\n        ok: false,\n        error: error instanceof Error ? error.message : String(error),\n      };\n    }\n  })()`);\n    if (!result) {\n        throw new CommandExecutionError('linux.do returned an empty browser response');\n    }\n    if (result.status === 401 || result.status === 403) {\n        throw new AuthRequiredError(LINUX_DO_DOMAIN, 'linux.do requires an active signed-in browser session');\n    }\n    if (result.error === 'Response is not valid JSON') {\n        throw new AuthRequiredError(LINUX_DO_DOMAIN, 'linux.do requires an active signed-in browser session');\n    }\n    if (!result.ok) {\n        throw new CommandExecutionError(result.error || `linux.do request failed: HTTP ${result.status ?? 'unknown'}`);\n    }\n    if (result.error) {\n        throw new CommandExecutionError(result.error, 'Please verify your linux.do session is still valid');\n    }\n    return result.data;\n}\ncli({\n    site: 'linux-do',\n    name: 'topic-content',\n    access: 'read',\n    description: 'Get the main topic body as Markdown',\n    domain: LINUX_DO_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    defaultFormat: 'plain',\n    args: [\n        { name: 'id', positional: true, type: 'int', required: true, help: 'Topic ID' },\n    ],","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linux-do/topic-content.js#L98-L134","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the topic ID is valid and the topic still exists in the web UI.","Wait and retry with backoff if the status is 429 or 5xx.","Slow down batch loops to stay under linux.do rate limits.","Print/log result.status to identify the exact HTTP code."],"exampleFix":"// before\nfor (const id of ids) {\n  results.push(extractTopicContent(await fetchTopicPayload(page, id), id));\n}\n// after\nfor (const id of ids) {\n  await sleep(1500); // respect rate limits\n  try {\n    results.push(extractTopicContent(await fetchTopicPayload(page, id), id));\n  } catch (e) {\n    console.error(`Topic ${id} failed: ${e.message}`);\n  }\n}","handlingStrategy":"retry","validationCode":"if (!Number.isInteger(id) || id <= 0) {\n  throw new Error('Refusing request: invalid topic id would 404');\n}","typeGuard":"const isHttpError = (e) => /linux\\.do request failed: HTTP/.test(e?.message ?? '');","tryCatchPattern":"try {\n  return await fetchTopicPayload(page, id);\n} catch (e) {\n  if (isHttpError(e)) {\n    const status = Number(e.message.match(/HTTP (\\d+)/)?.[1] ?? 0);\n    if (status === 429 || status >= 500) return retryWithBackoff(() => fetchTopicPayload(page, id));\n  } else throw e;\n}","preventionTips":["Throttle requests to avoid 429s","Validate topic IDs before fetching","Retry 5xx with exponential backoff"],"tags":["http","network","rate-limit","discourse"],"backgroundTag":"http-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}