{"record":{"id":"8802bc85fe5bc234","repo":"alibaba/page-agent","slug":"unknown","errorCode":"UNKNOWN","errorMessage":"HTTP ${response.status}: ${errorMessage}","messagePattern":"HTTP (.+?): (.+?)","errorType":"http","errorClass":"InvokeError","httpStatus":null,"severity":"error","filePath":"packages/llms/src/OpenAIClient.ts","lineNumber":122,"sourceCode":"\t\t\t\t\t`Authentication failed: ${errorMessage}`,\n\t\t\t\t\terrorData\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (response.status === 429) {\n\t\t\t\tthrow new InvokeError(\n\t\t\t\t\tInvokeErrorTypes.RATE_LIMIT,\n\t\t\t\t\t`Rate limit exceeded: ${errorMessage}`,\n\t\t\t\t\terrorData\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (response.status >= 500) {\n\t\t\t\tthrow new InvokeError(\n\t\t\t\t\tInvokeErrorTypes.SERVER_ERROR,\n\t\t\t\t\t`Server error: ${errorMessage}`,\n\t\t\t\t\terrorData\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new InvokeError(\n\t\t\t\tInvokeErrorTypes.UNKNOWN,\n\t\t\t\t`HTTP ${response.status}: ${errorMessage}`,\n\t\t\t\terrorData\n\t\t\t)\n\t\t}\n\n\t\t// 4. Parse and validate response\n\t\tlet data: any\n\t\ttry {\n\t\t\tdata = await response.json()\n\t\t} catch (error) {\n\t\t\tif ((error as any)?.name === 'AbortError') throw error\n\t\t\tthrow new InvokeError(\n\t\t\t\tInvokeErrorTypes.INVALID_RESPONSE,\n\t\t\t\t'Response body is not valid JSON',\n\t\t\t\terror\n\t\t\t)\n\t\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/alibaba/page-agent/blob/d02db1ee7c41f5315beda88bab2fe935c580f662/packages/llms/src/OpenAIClient.ts#L104-L140","documentation":"The endpoint returned a non-OK HTTP status that is not 401/403, 429, or 5xx — typically 400/404/405/422 class errors. The status code and the provider's error message are embedded, with the parsed body attached.","triggerScenarios":"invoke() with a malformed payload the provider rejects with 400 (bad model name, invalid message format, unknown tool schema); 404 from a wrong baseURL path (missing /v1) or nonexistent model/deployment; 422 validation errors from compatible providers.","commonSituations":"Model name typo or model not available to this endpoint; baseURL missing the /v1 path segment so /chat/completions 404s; tool definitions with unsupported JSON schema features; provider-specific required params missing; version drift between client payload shape and provider API.","solutions":["Read the embedded message and errorData — providers are specific about what's wrong","Verify the model name is valid for this endpoint (GET <baseURL>/models)","Check baseURL includes the correct path prefix (e.g. /v1)","If 400 on tool calls, simplify tool parameter schemas and re-test"],"exampleFix":"// before\nnew OpenAIClient({ baseURL: 'https://api.openai.com', model: 'gpt4-turbo' }) // 404s\n\n// after\nnew OpenAIClient({ baseURL: 'https://api.openai.com/v1', model: 'gpt-4-turbo' })","handlingStrategy":"try-catch","validationCode":"// smoke-test config before use\nconst res = await fetch(`${cfg.baseURL}/models`, { headers: { Authorization: `Bearer ${cfg.apiKey}` } })\nif (!res.ok) throw new Error(`Endpoint config problem: HTTP ${res.status}`)","typeGuard":"const isUnknownHttpError = (e: unknown): e is InvokeError =>\n  e instanceof InvokeError && e.code === 'UNKNOWN' && /^HTTP \\d+/.test(e.message)","tryCatchPattern":"try {\n  await client.invoke(req)\n} catch (e) {\n  if (isUnknownHttpError(e)) {\n    console.error('Inspect status & body:', e.message, e.details) // includes errorData\n    throw e\n  }\n  throw e\n}","preventionTips":["Verify model names against GET /models once at startup","Keep baseURL path prefixes (/v1) in config constants, not string literals","Test tool schemas minimally before shipping complex ones"],"tags":["http-error","bad-request","openai-client"],"backgroundTag":"http-error-response","analyzedSha":"d02db1ee7c41f5315beda88bab2fe935c580f662","analyzedAt":"2026-08-28T19:39:48.634Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}