{"record":{"id":"0bea8569196d7bbc","repo":"diegosouzapw/OmniRoute","slug":"await-errormessage-res","errorCode":null,"errorMessage":"${await errorMessage(res)}","messagePattern":"\\$\\{await errorMessage\\(res\\)\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/inspector/agentBridgeMaintenanceApi.ts","lineNumber":31,"sourceCode":" * never pulls their DB dependencies.\n */\nimport type { DiagnosticReport } from \"@/mitm/inspector/diagnostics\";\nimport type { AgentBridgeConfig, ImportResult } from \"@/lib/inspector/configPortability\";\n\nexport interface DiagnoseResult extends DiagnosticReport {\n  /** The port the diagnose route probed (echoed back for display). */\n  port: number;\n}\n\n/** Extract the sanitized server error message, falling back to the status. */\nasync function errorMessage(res: Response): Promise<string> {\n  const body = (await res.json().catch(() => null)) as { error?: { message?: string } } | null;\n  return body?.error?.message ?? `HTTP ${res.status}`;\n}\n\nasync function requestJson<T>(url: string, init?: RequestInit): Promise<T> {\n  const res = await fetch(url, init);\n  if (!res.ok) throw new Error(await errorMessage(res));\n  return (await res.json()) as T;\n}\n\n/** Run the capture-pipeline self-test (server/cert/dns reachability). */\nexport function runDiagnose(agentId?: string): Promise<DiagnoseResult> {\n  const url = agentId\n    ? `/api/tools/agent-bridge/diagnose?agentId=${encodeURIComponent(agentId)}`\n    : \"/api/tools/agent-bridge/diagnose\";\n  return requestJson<DiagnoseResult>(url);\n}\n\n/** Untrust + remove the MITM root CA from the OS store (explicit, idempotent). */\nexport function removeCaCert(sudoPassword?: string): Promise<{ trusted: boolean }> {\n  return requestJson<{ ok: boolean; trusted: boolean }>(\"/api/tools/agent-bridge/cert\", {\n    method: \"DELETE\",\n    headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify(sudoPassword ? { sudoPassword } : {}),\n  });","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/inspector/agentBridgeMaintenanceApi.ts#L13-L49","documentation":"Error \"${await errorMessage(res)}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/inspector/agentBridgeMaintenanceApi.ts:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}