{"record":{"id":"a6f1a1b4aaa5f81b","repo":"jackwener/OpenCLI","slug":"ietf-datatracker-returned-404-for-url","errorCode":null,"errorMessage":"IETF datatracker returned 404 for ${url}.","messagePattern":"IETF datatracker returned 404 for (.+?)\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":404,"severity":"error","filePath":"clis/rfc/utils.js","lineNumber":46,"sourceCode":"    if (n > 999999) {\n        throw new ArgumentError('rfc number must be <= 999999');\n    }\n    return n;\n}\n\nexport async function rfcFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that datatracker.ietf.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `IETF datatracker returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(`${label} returned HTTP 429 (rate limited)`);\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);\n    }\n    let body;\n    try {\n        body = await resp.json();\n    }\n    catch (err) {\n        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);\n    }\n    return body;\n}\n\n// IETF datatracker timestamps are like \"2022-02-19 08:46:51\" (no T, no Z)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/rfc/utils.js#L28-L64","documentation":"rfcFetch translates an HTTP 404 from the IETF datatracker into EmptyResultError, indicating no document exists at the requested URL. This distinguishes 'not found' from genuine network or server errors.","triggerScenarios":"Requesting doc.json for an RFC number that does not exist (e.g. rfc99999), a mistyped number, or a name that maps to no datatracker document.","commonSituations":"Typos in RFC numbers, querying numbers reserved but never published, or stale scripts referencing restructured datatracker URLs.","solutions":["Verify the RFC number exists on datatracker.ietf.org before fetching.","Correct typos in the requested number.","Catch EmptyResultError and show 'RFC not found' instead of a generic error.","If a URL pattern changed, update RFC_BASE usage to the current datatracker API."],"exampleFix":"// before\nrfc rfc --number 99999   // 404\n// after\nrfc rfc --number 9000","handlingStrategy":"try-catch","validationCode":"// Pre-validate the RFC exists in a local index\nconst knownRfcs = new Set([791, 2616, 9000]);\nif (!knownRfcs.has(n)) console.warn(`RFC ${n} may not exist`);","typeGuard":"null","tryCatchPattern":"try {\n  const doc = await rfcFetch(url, label);\n} catch (err) {\n  if (err instanceof EmptyResultError) {\n    console.error(`RFC not found: ${url}`);\n  } else throw err;\n}","preventionTips":["Verify numbers against the official RFC index before lookup.","Treat 404 as 'not found', not as a bug to retry.","Fix typos: an extra digit yields 404, not a range error.","Keep RFC_BASE URLs in sync with current datatracker API paths."],"tags":["http-404","not-found","ietf-datatracker"],"backgroundTag":"http-404-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}