From 88a35ed057935489519086295379eb2aef065cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 17 Jun 2025 19:23:52 +0200 Subject: [PATCH] Fix crash when integration is triggering invalid requests (#3346) --- .changeset/khaki-bees-count.md | 5 +++++ .../src/components/DocumentView/Integration/render.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/khaki-bees-count.md diff --git a/.changeset/khaki-bees-count.md b/.changeset/khaki-bees-count.md new file mode 100644 index 000000000..a481690e2 --- /dev/null +++ b/.changeset/khaki-bees-count.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Fix crash when integration is triggering invalid requests. diff --git a/packages/gitbook/src/components/DocumentView/Integration/render.ts b/packages/gitbook/src/components/DocumentView/Integration/render.ts index a9a86c9e5..4e683e0dc 100644 --- a/packages/gitbook/src/components/DocumentView/Integration/render.ts +++ b/packages/gitbook/src/components/DocumentView/Integration/render.ts @@ -21,10 +21,13 @@ export async function fetchSafeIntegrationUI( request, }), - // The API can respond with a 400 error if the integration is not installed - // and 404 if the integration is not found. - // The API can also respond with a 502 error if the integration is not generating a proper response. - [404, 400, 502] + // The API can respond with certain errors that are expected to happen. + [ + 404, // Integration has been uninstalled + 400, // Integration is rejecting its own request + 422, // Integration is triggering an invalid request, failing at the validation step + 502, // Integration is failing in an unexpected way + ] ); return output;