{"record":{"id":"ee765156a2e70fdd","repo":"jackwener/OpenCLI","slug":"mdn-search-returned-http-resp-status","errorCode":null,"errorMessage":"mdn search returned HTTP ${resp.status}","messagePattern":"mdn search returned HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/mdn/search.js","lineNumber":75,"sourceCode":"        const query = requireString(args.query, 'query');\n        const limit = requireBoundedInt(args.limit, 10, 50);\n        const locale = requireLocale(args.locale);\n        const url = `${MDN_BASE}/api/v1/search?q=${encodeURIComponent(query)}&locale=${encodeURIComponent(locale)}&size=${limit}`;\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(`mdn search request failed: ${err?.message ?? err}`);\n        }\n        if (resp.status === 429) {\n            throw new CommandExecutionError(\n                'mdn search returned HTTP 429 (rate limited)',\n                'MDN throttles bursty traffic; wait a few seconds and retry.',\n            );\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`mdn search returned HTTP ${resp.status}`);\n        }\n        let body;\n        try {\n            body = await resp.json();\n        }\n        catch (err) {\n            throw new CommandExecutionError(`mdn search returned malformed JSON: ${err?.message ?? err}`);\n        }\n        const docs = Array.isArray(body?.documents) ? body.documents : [];\n        if (!docs.length) {\n            throw new EmptyResultError('mdn search', `No MDN results matched \"${query}\" (locale ${locale}).`);\n        }\n        return docs.slice(0, limit).map((doc, i) => ({\n            rank: i + 1,\n            title: String(doc.title ?? ''),\n            slug: String(doc.slug ?? ''),\n            locale: String(doc.locale ?? locale),\n            summary: String(doc.summary ?? '').replace(/\\s+/g, ' ').trim(),","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/mdn/search.js#L57-L93","documentation":"The MDN search API returned a non-OK, non-429 HTTP status (e.g. 500, 502, 503, 403). The adapter surfaces the raw status code in this CommandExecutionError. It signals a server-side or gateway problem rather than a client input issue.","triggerScenarios":"MDN server errors (5xx), API gateway/auth blocks (403), or any !resp.ok status other than the handled 429.","commonSituations":"MDN downtime or maintenance; CDN outages; blocked IPs; API changes returning unexpected statuses.","solutions":["Check MDN status (visit developer.mozilla.org in a browser) and retry later if 5xx.","If 403, check whether your IP/proxy is blocked and adjust network setup.","Inspect the status code in the message to decide: 5xx retry with backoff, 4xx fix request.","Pin/fall back to a local docs search if MDN is unavailable."],"exampleFix":"// before\nconst r = await mdnSearch({ query: 'weakmap' });\n// after\ntry {\n  const r = await mdnSearch({ query: 'weakmap' });\n} catch (e) {\n  const m = /HTTP (\\d+)/.exec(e.message);\n  if (m && +m[1] >= 500) return retryLater(e);\n  throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await mdnSearch({ query }); } catch (e) {\n  const m = /HTTP (\\d+)/.exec(e.message);\n  if (m && +m[1] >= 500) return retryWithBackoff(() => mdnSearch({ query }));\n  throw e;\n}","preventionTips":["Retry only 5xx statuses; investigate 4xx","Monitor MDN status before bulk jobs","Provide a local docs fallback for CI"],"tags":["http","network","server-error"],"backgroundTag":"http-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}