alibaba/page-agent · error · InvokeError
UNKNOWN
UNKNOWN
Error message
HTTP ${response.status}: ${errorMessage} What it means
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.
Source
Thrown at packages/llms/src/OpenAIClient.ts:122
`Authentication failed: ${errorMessage}`,
errorData
)
}
if (response.status === 429) {
throw new InvokeError(
InvokeErrorTypes.RATE_LIMIT,
`Rate limit exceeded: ${errorMessage}`,
errorData
)
}
if (response.status >= 500) {
throw new InvokeError(
InvokeErrorTypes.SERVER_ERROR,
`Server error: ${errorMessage}`,
errorData
)
}
throw new InvokeError(
InvokeErrorTypes.UNKNOWN,
`HTTP ${response.status}: ${errorMessage}`,
errorData
)
}
// 4. Parse and validate response
let data: any
try {
data = await response.json()
} catch (error) {
if ((error as any)?.name === 'AbortError') throw error
throw new InvokeError(
InvokeErrorTypes.INVALID_RESPONSE,
'Response body is not valid JSON',
error
)
}View on GitHub (pinned to d02db1ee7c)
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
Example fix
// before
new OpenAIClient({ baseURL: 'https://api.openai.com', model: 'gpt4-turbo' }) // 404s
// after
new OpenAIClient({ baseURL: 'https://api.openai.com/v1', model: 'gpt-4-turbo' }) Defensive patterns
Strategy: try-catch
Validate before calling
// smoke-test config before use
const res = await fetch(`${cfg.baseURL}/models`, { headers: { Authorization: `Bearer ${cfg.apiKey}` } })
if (!res.ok) throw new Error(`Endpoint config problem: HTTP ${res.status}`) Type guard
const isUnknownHttpError = (e: unknown): e is InvokeError => e instanceof InvokeError && e.code === 'UNKNOWN' && /^HTTP \d+/.test(e.message)
Try / catch
try {
await client.invoke(req)
} catch (e) {
if (isUnknownHttpError(e)) {
console.error('Inspect status & body:', e.message, e.details) // includes errorData
throw e
}
throw e
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of alibaba/page-agent@d02db1ee7c (2026-08-28).
Data as JSON: /api/errors/8802bc85fe5bc234.
Report an issue: GitHub.