Skip to content

Commit 1d4e22b

Browse files
authored
Throw exposable errors when integrations are missing auth (#926)
1 parent 0a7b780 commit 1d4e22b

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

.changeset/cute-mammals-knock.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@gitbook/integration-figma': minor
3+
'@gitbook/integration-slack': minor
4+
---
5+
6+
Figma and slack exposable error

.changeset/witty-geckos-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-slack': minor
3+
---
4+
5+
Throw exposable error when slack is not configured

bun.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979
"integrations/fathom": {
8080
"name": "@gitbook/integration-fathom",
81-
"version": "0.5.2",
81+
"version": "0.6.0",
8282
"dependencies": {
8383
"@gitbook/api": "*",
8484
"@gitbook/runtime": "*",
@@ -101,7 +101,7 @@
101101
},
102102
"integrations/formspree": {
103103
"name": "@gitbook/integration-formspree",
104-
"version": "0.2.9",
104+
"version": "0.2.11",
105105
"dependencies": {
106106
"@gitbook/runtime": "workspace:*",
107107
},
@@ -204,7 +204,7 @@
204204
},
205205
"integrations/heap": {
206206
"name": "@gitbook/integration-heap",
207-
"version": "0.5.2",
207+
"version": "0.6.0",
208208
"dependencies": {
209209
"@gitbook/api": "*",
210210
"@gitbook/runtime": "*",
@@ -227,7 +227,7 @@
227227
},
228228
"integrations/hotjar": {
229229
"name": "@gitbook/integration-hotjar",
230-
"version": "0.5.2",
230+
"version": "0.6.0",
231231
"dependencies": {
232232
"@gitbook/api": "*",
233233
"@gitbook/runtime": "*",
@@ -331,7 +331,7 @@
331331
},
332332
"integrations/mailchimp": {
333333
"name": "@gitbook/integration-mailchimp",
334-
"version": "1.1.2",
334+
"version": "1.2.0",
335335
"dependencies": {
336336
"@gitbook/runtime": "*",
337337
"itty-router": "^2.6.1",
@@ -369,7 +369,7 @@
369369
},
370370
"integrations/mixpanel": {
371371
"name": "@gitbook/integration-mixpanel",
372-
"version": "0.4.2",
372+
"version": "0.5.0",
373373
"dependencies": {
374374
"@gitbook/api": "*",
375375
"@gitbook/runtime": "*",
@@ -407,7 +407,7 @@
407407
},
408408
"integrations/plausible": {
409409
"name": "@gitbook/integration-plausible",
410-
"version": "0.5.2",
410+
"version": "0.6.0",
411411
"dependencies": {
412412
"@gitbook/api": "*",
413413
"@gitbook/runtime": "*",
@@ -419,7 +419,7 @@
419419
},
420420
"integrations/posthog": {
421421
"name": "@gitbook/integration-posthog",
422-
"version": "1.0.0",
422+
"version": "1.1.0",
423423
"dependencies": {
424424
"@gitbook/api": "*",
425425
"@gitbook/runtime": "*",
@@ -431,7 +431,7 @@
431431
},
432432
"integrations/reo": {
433433
"name": "@gitbook/integration-reo.dev",
434-
"version": "0.3.2",
434+
"version": "0.4.0",
435435
"dependencies": {
436436
"@gitbook/api": "*",
437437
"@gitbook/runtime": "*",
@@ -614,7 +614,7 @@
614614
},
615615
"packages/api": {
616616
"name": "@gitbook/api",
617-
"version": "0.129.0",
617+
"version": "0.131.0",
618618
"dependencies": {
619619
"event-iterator": "^2.0.0",
620620
"eventsource-parser": "^3.0.0",
@@ -669,7 +669,7 @@
669669
},
670670
"packages/runtime": {
671671
"name": "@gitbook/runtime",
672-
"version": "0.20.0",
672+
"version": "0.21.0",
673673
"dependencies": {
674674
"@gitbook/api": "*",
675675
},

integrations/figma/src/figma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ExposableError } from '@gitbook/runtime';
12
import { FigmaRuntimeContext } from './types';
23

34
export interface FileNodeId {
@@ -135,7 +136,7 @@ export async function fetchFigmaAPI<T>(
135136
): Promise<T> {
136137
const accessToken = environment.installation?.configuration.oauth_credentials?.access_token;
137138
if (!accessToken) {
138-
throw new Error('Missing authentication');
139+
throw new ExposableError('Integration is not authenticated');
139140
}
140141

141142
const url = new URL(`https://api.figma.com/v1/${path}`);

integrations/slack/src/slack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Logger } from '@gitbook/runtime';
1+
import { ExposableError, Logger } from '@gitbook/runtime';
22

33
import { SlackRuntimeContext } from './configuration';
44

@@ -110,7 +110,7 @@ export async function slackAPI<Result>(
110110
environment.installation?.configuration.oauth_credentials?.access_token;
111111

112112
if (!accessToken) {
113-
throw new Error('No authentication token provided');
113+
throw new ExposableError('Integration is not authenticated');
114114
}
115115

116116
const url = request.responseUrl

0 commit comments

Comments
 (0)