{"record":{"id":"f8e6b214fc8e233f","repo":"jackwener/OpenCLI","slug":"weread-official-apiname-request-failed","errorCode":null,"errorMessage":"weread-official ${apiName} request failed","messagePattern":"weread-official (.+?) request failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weread-official/utils.js","lineNumber":98,"sourceCode":"\n    let response;\n    try {\n        response = await fetch(WEREAD_GATEWAY_URL, {\n            method: 'POST',\n            headers: {\n                Authorization: `Bearer ${key}`,\n                'Content-Type': 'application/json',\n            },\n            body: JSON.stringify(body),\n            signal: controller.signal,\n        });\n    }\n    catch (error) {\n        if (error?.name === 'AbortError') {\n            throw new TimeoutError(`weread-official ${apiName}`, Math.round(timeoutMs / 1000));\n        }\n        const detail = error instanceof Error ? error.message : String(error);\n        throw new CommandExecutionError(`weread-official ${apiName} request failed`, detail);\n    }\n    finally {\n        clearTimeout(timer);\n    }\n\n    if (!response.ok) {\n        throw new CommandExecutionError(\n            `weread-official ${apiName} HTTP ${response.status}`,\n            'Check WeRead gateway availability and that WEREAD_API_KEY is still valid.',\n        );\n    }\n\n    let payload;\n    try {\n        payload = await response.json();\n    }\n    catch (error) {\n        const detail = error instanceof Error ? error.message : String(error);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weread-official/utils.js#L80-L116","documentation":"Generic fetch failure inside callGateway. TimeoutError handles aborts; any other thrown error (network reset, invalid URL, socket hangup) becomes CommandExecutionError with the original error message as detail.","triggerScenarios":"Connection reset mid-request, malformed request URL, DNS resolution failure, or fetch throwing synchronously — anything that is not an AbortError in the catch block.","commonSituations":"VPN dropping mid-call; gateway closing keep-alive connections; Node fetch failing on an unreachable host; mistyped gateway base URL in configuration.","solutions":["Read error.detail for the underlying message (e.g. getaddrinfo ENOTFOUND).","Fix DNS/proxy/connectivity indicated by the detail message.","Verify the gateway base URL/domain configuration.","Retry with backoff for transient socket errors."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"new URL(gatewayUrl); // throws early if the base URL is malformed","typeGuard":"const isFetchError = (e) => e instanceof CommandExecutionError && /request failed/.test(e.message);","tryCatchPattern":"try {\n  return await callGateway(apiName, params);\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.detail) {\n    console.error(`weread-official ${apiName}: underlying cause: ${e.detail}`);\n  }\n  throw e;\n}","preventionTips":["Log error.detail — it carries the original fetch message","Verify gateway base URL configuration","Handle transient network errors with bounded retries","Avoid calling the gateway from flaky connections without backoff"],"tags":["network","fetch","http"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}