{"record":{"id":"ca9a623d39339f66","repo":"hcengineering/platform","slug":"platform-status-badrequest-ca9a62","errorCode":"platform.status.BadRequest","errorMessage":"Bad request","messagePattern":"Bad request","errorType":"http","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"packages/integration-client/src/request.ts","lineNumber":92,"sourceCode":"      return JSON.parse(text)\n    } catch (error) {\n      console.warn('Failed to parse JSON response:', text, error)\n      return undefined\n    }\n  } else if (response.status === 202) {\n    return undefined\n  } else if (response.status === 401) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.Unauthorized, {}))\n  } else if (response.status === 403) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))\n  } else if (response.status === 404) {\n    throw new PlatformError(\n      new Status(Severity.ERROR, platform.status.ResourceNotFound, { resource: options.path ?? '' })\n    )\n  } else if (response.status >= 500) {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.InternalServerError, {}))\n  } else {\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.BadRequest, { status: response.status }))\n  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":95,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/integration-client/src/request.ts#L74-L95","documentation":"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.","triggerScenarios":"Any request() call where the integration service responds with an unhandled status code — typically 400, but also 409, 422, 429, redirects handled oddly, etc.","commonSituations":"Malformed or schema-invalid request body; invalid query parameters; rate limiting (429) surfacing as 'Bad request'; API contract drift after a version change.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":"function isBadRequest (err: unknown): err is PlatformError {\n  return err instanceof PlatformError && (err.status.code as number) === platform.status.BadRequest\n}","tryCatchPattern":"try {\n  await client.request(...)\n} catch (err) {\n  if (isBadRequest(err)) {\n    const httpStatus = (err.status.params as { status?: number }).status\n    // branch on httpStatus (400 validate payload, 429 backoff, ...)\n  } else {\n    throw err\n  }\n}","preventionTips":["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."],"tags":["http-400","bad-request","validation"],"backgroundTag":"bad-request","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}