{"record":{"id":"85f8f46f90c16702","repo":"jackwener/OpenCLI","slug":"mubu-path-http-result-status-result-erro","errorCode":null,"errorMessage":"mubu: ${path}: HTTP ${result.status} ${result.error ?? ''}","messagePattern":"mubu: (.+?): HTTP (.+?) (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/mubu/utils.js","lineNumber":45,"sourceCode":"        xhr.open('POST', ${JSON.stringify(url)}, true);\n        xhr.setRequestHeader('Content-Type', 'application/json');\n        xhr.setRequestHeader('Jwt-Token', token);\n        xhr.onload = () => {\n          let data = null;\n          try { data = JSON.parse(xhr.responseText); } catch {}\n          resolve({ ok: xhr.status >= 200 && xhr.status < 300, status: xhr.status, data });\n        };\n        xhr.onerror = () => resolve({ ok: false, status: 0, data: null, error: 'network error' });\n        xhr.send(${JSON.stringify(JSON.stringify(body))});\n      });\n    })()\n  `);\n\n  if (!result || result.error === 'no token') {\n    throw new AuthRequiredError(MUBU_DOMAIN, AUTH_HINT);\n  }\n  if (!result.ok || !result.data) {\n    throw new CommandExecutionError(`mubu: ${path}: HTTP ${result.status} ${result.error ?? ''}`);\n  }\n\n  const { data } = result;\n  if (data.code !== 0) {\n    if (isAuthFailure(data.code, data.message)) {\n      throw new AuthRequiredError(MUBU_DOMAIN, AUTH_HINT);\n    }\n    throw new CommandExecutionError(`mubu: ${path}: code=${data.code} ${data.message ?? ''}`);\n  }\n\n  return data.data;\n}\n\nexport function formatDate(ts) {\n  if (!ts) return '';\n  const d = new Date(ts);\n  const pad = (n) => String(n).padStart(2, '0');\n  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/mubu/utils.js#L27-L63","documentation":"When the in-page XHR fails (non-2xx status, network error, or an unparseable/empty response body), mubuPost throws CommandExecutionError with the API path, HTTP status, and error detail. This is the generic transport-level failure path, distinct from auth and API business-code errors.","triggerScenarios":"api2.mubu.com unreachable (offline, DNS, firewall), server returns 500/404, xhr.onerror fires ('network error'), or the response body is not valid JSON so data is null.","commonSituations":"Corporate proxies blocking the domain, mubu API outage or endpoint rename, browser extension interference, or rate limiting producing 429.","solutions":["Check network connectivity / proxy settings for api2.mubu.com.","Retry after a short delay if the status is 5xx or 429 (transient issues).","Verify the API path is still valid — the error names the exact path that failed."],"exampleFix":"// before\nconst data = await mubuPost(page, '/doc/list', body); // throws on 500\n// after\ntry {\n  const data = await mubuPost(page, '/doc/list', body);\n} catch (e) {\n  if (e instanceof CommandExecutionError && /HTTP 5\\d\\d/.test(e.message)) {\n    await new Promise(r => setTimeout(r, 2000));\n    return mubuPost(page, '/doc/list', body); // retry once\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"// reachability probe before the call\nawait page.goto('https://api2.mubu.com', { waitUntil: 'domcontentloaded', timeout: 10000 }).catch(() => { throw new Error('api2.mubu.com unreachable'); });","typeGuard":"const isTransportError = (e) => e instanceof CommandExecutionError && /HTTP \\d+|network error/.test(e.message);","tryCatchPattern":"try {\n  return await mubuPost(page, path, body);\n} catch (e) {\n  if (isTransportError(e) && attempts < 3) {\n    await new Promise(r => setTimeout(r, 1000 * 2 ** attempts));\n    return retry(attempts + 1);\n  }\n  throw e;\n}","preventionTips":["Add exponential backoff for 5xx/429 and network errors.","Verify proxy/firewall rules allow api2.mubu.com.","Log the failing path and status from the error message for diagnosis."],"tags":["network","http-error","api"],"backgroundTag":"http-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}