hcengineering/platform · error · PlatformError
platform.status.BadRequest
platform.status.BadRequest
Error message
Bad request
What it means
The integration client's fallback branch maps any unrecognized non-success HTTP status (not 2xx, 202, 401, 403, 404, or >=500) to PlatformError with status.BadRequest and message 'Bad request', including the raw HTTP status in the params. It usually means the request body/params were rejected by the server.
Source
Thrown at packages/integration-client/src/request.ts:92
return JSON.parse(text)
} catch (error) {
console.warn('Failed to parse JSON response:', text, error)
return undefined
}
} else if (response.status === 202) {
return undefined
} else if (response.status === 401) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.Unauthorized, {}))
} else if (response.status === 403) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
} else if (response.status === 404) {
throw new PlatformError(
new Status(Severity.ERROR, platform.status.ResourceNotFound, { resource: options.path ?? '' })
)
} else if (response.status >= 500) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.InternalServerError, {}))
} else {
throw new PlatformError(new Status(Severity.ERROR, platform.status.BadRequest, { status: response.status }))
}
}
View on GitHub (pinned to 63e28dc964)
Solutions
- Read the actual HTTP status from the error status params and handle it accordingly.
- Validate the request payload against the service's expected schema before sending.
- Check for API version mismatch between client and service (contract drift).
- If it is 429, add client-side rate limiting/backoff.
Defensive patterns
Strategy: validation
Type guard
function isBadRequest (err: unknown): err is PlatformError {
return err instanceof PlatformError && (err.status.code as number) === platform.status.BadRequest
} Try / catch
try {
await client.request(...)
} catch (err) {
if (isBadRequest(err)) {
const httpStatus = (err.status.params as { status?: number }).status
// branch on httpStatus (400 validate payload, 429 backoff, ...)
} else {
throw err
}
} Prevention
- Validate request payloads against the service schema before sending.
- Pin and align client/service API versions to prevent contract drift.
- Read err.status.params.status to recover the real HTTP code when debugging.
When it happens
Trigger: Any request() call where the integration service responds with an unhandled status code — typically 400, but also 409, 422, 429, redirects handled oddly, etc.
Common situations: Malformed or schema-invalid request body; invalid query parameters; rate limiting (429) surfacing as 'Bad request'; API contract drift after a version change.
Understand the failure class
Background: BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries — this error's family across 8 libraries.
Related errors
- Failed to load server config
- getDisplayMedia not supported
- No screen access granted
- account.status.BadRequest
- account.status.BadRequest
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/ca9a623d39339f66.
Report an issue: GitHub.