Skip to content

Commit b390f15

Browse files
committed
fix(integrations): pass through unknown ketch consent values, show rootly title with detail, decrypt 1password vault details
1 parent 95fee97 commit b390f15

46 files changed

Lines changed: 138 additions & 189 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/sim/blocks/blocks/ketch.test.ts‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,22 @@ describe('KetchBlock', () => {
5353
})
5454
})
5555

56-
it('rejects an allowed value Ketch would silently record as denied', () => {
56+
it('sends an unrecognized allowed value unchanged', () => {
5757
const buildBody = setConsentTool.request.body
5858
if (!buildBody) throw new Error('set consent has no body builder')
5959

60-
expect(() =>
61-
buildBody({
62-
organizationCode: 'org',
63-
propertyCode: 'web',
64-
environmentCode: 'production',
65-
identities: { email: 'a@example.com' },
66-
purposes: { analytics: { allowed: 'yes' } },
67-
})
68-
).toThrow('invalid "allowed" value')
60+
const body = buildBody({
61+
organizationCode: 'org',
62+
propertyCode: 'web',
63+
environmentCode: 'production',
64+
identities: { email: 'a@example.com' },
65+
purposes: { analytics: { allowed: 'yes' }, marketing: { allowed: '' } },
66+
})
67+
if (!body || typeof body === 'string' || body instanceof FormData) {
68+
throw new Error('Expected a JSON body')
69+
}
70+
71+
expect(body.purposes).toEqual({ analytics: { allowed: 'yes' }, marketing: { allowed: '' } })
6972
})
7073

7174
it('surfaces the message of a Ketch error envelope', async () => {

‎apps/sim/lib/internal/onepassword/operations.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function executeOnePasswordListVaults(
8686
const credentials = resolveCredentials(input)
8787
if (credentials.mode === 'service_account') {
8888
const client = await createOnePasswordClient(credentials.serviceAccountToken, context.signal)
89-
const vaults = await runSdk(context.signal, () => client.vaults.list())
89+
const vaults = await runSdk(context.signal, () => client.vaults.list({ decryptDetails: true }))
9090
const normalized = vaults.map(normalizeSdkVault)
9191
const filter = input.filter
9292
if (!filter) return normalized
@@ -118,7 +118,7 @@ export async function executeOnePasswordGetVault(
118118
const credentials = resolveCredentials(input)
119119
if (credentials.mode === 'service_account') {
120120
const client = await createOnePasswordClient(credentials.serviceAccountToken, context.signal)
121-
const vaults = await runSdk(context.signal, () => client.vaults.list())
121+
const vaults = await runSdk(context.signal, () => client.vaults.list({ decryptDetails: true }))
122122
const vault = vaults.find((candidate) => candidate.id === input.vaultId)
123123
if (!vault) {
124124
throw new OnePasswordOperationError(404, { error: 'Vault not found' })

‎apps/sim/tools/ketch/set_consent.ts‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const ALLOWED_ALIASES = new Map([
1212

1313
/**
1414
* Ketch stores `allowed` as the string `"true"` or `"false"` and records any other value
15-
* (including `"granted"`) as denied, so booleans and granted/denied are converted first and
16-
* anything else is rejected rather than silently saved as denied.
15+
* (including `"granted"`) as denied, so booleans and granted/denied are converted first.
16+
* Any other value is sent unchanged, as before.
1717
*/
1818
function normalizePurposes(purposes: KetchSetConsentParams['purposes']): Record<string, unknown> {
1919
const normalized: Record<string, unknown> = {}
2020
for (const [code, setting] of Object.entries(purposes ?? {})) {
21-
if (!setting || typeof setting !== 'object' || setting.allowed === undefined) {
21+
if (!setting || typeof setting !== 'object') {
2222
normalized[code] = setting
2323
continue
2424
}
@@ -29,12 +29,7 @@ function normalizePurposes(purposes: KetchSetConsentParams['purposes']): Record<
2929
: typeof allowed === 'string'
3030
? ALLOWED_ALIASES.get(allowed.trim().toLowerCase())
3131
: undefined
32-
if (!alias) {
33-
throw new Error(
34-
`Purpose "${code}" has an invalid "allowed" value: use "true" or "false" ("granted"/"denied" are also accepted)`
35-
)
36-
}
37-
normalized[code] = { ...setting, allowed: alias }
32+
normalized[code] = alias ? { ...setting, allowed: alias } : setting
3833
}
3934
return normalized
4035
}

‎apps/sim/tools/rootly/acknowledge_alert.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
RootlyAcknowledgeAlertParams,
33
RootlyAcknowledgeAlertResponse,
44
} from '@/tools/rootly/types'
5+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
56
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
67
import type { ToolConfig } from '@/tools/types'
78
import { safeUrlPathSegment } from '@/tools/url-path'
@@ -48,10 +49,7 @@ export const rootlyAcknowledgeAlertTool: ToolConfig<
4849
return {
4950
success: false,
5051
output: { alert: {} as RootlyAcknowledgeAlertResponse['output']['alert'] },
51-
error:
52-
errorData.errors?.[0]?.detail ||
53-
errorData.errors?.[0]?.title ||
54-
`HTTP ${response.status}: ${response.statusText}`,
52+
error: rootlyErrorMessage(errorData, response),
5553
}
5654
}
5755

‎apps/sim/tools/rootly/add_incident_event.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
RootlyAddIncidentEventParams,
33
RootlyAddIncidentEventResponse,
44
} from '@/tools/rootly/types'
5+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
56
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
67
import type { ToolConfig } from '@/tools/types'
78
import { safeUrlPathSegment } from '@/tools/url-path'
@@ -73,10 +74,7 @@ export const rootlyAddIncidentEventTool: ToolConfig<
7374
createdAt: '',
7475
updatedAt: '',
7576
},
76-
error:
77-
errorData.errors?.[0]?.detail ||
78-
errorData.errors?.[0]?.title ||
79-
`HTTP ${response.status}: ${response.statusText}`,
77+
error: rootlyErrorMessage(errorData, response),
8078
}
8179
}
8280

‎apps/sim/tools/rootly/add_subscribers.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RootlyAddSubscribersParams, RootlyIncidentActionResponse } from '@/tools/rootly/types'
2+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
23
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
34
import type { ToolConfig } from '@/tools/types'
45
import { safeUrlPathSegment } from '@/tools/url-path'
@@ -58,10 +59,7 @@ export const rootlyAddSubscribersTool: ToolConfig<
5859
return {
5960
success: false,
6061
output: { incident: {} as RootlyIncidentActionResponse['output']['incident'] },
61-
error:
62-
errorData.errors?.[0]?.detail ||
63-
errorData.errors?.[0]?.title ||
64-
`HTTP ${response.status}: ${response.statusText}`,
62+
error: rootlyErrorMessage(errorData, response),
6563
}
6664
}
6765

‎apps/sim/tools/rootly/assign_incident_role.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
RootlyAssignIncidentRoleParams,
33
RootlyIncidentActionResponse,
44
} from '@/tools/rootly/types'
5+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
56
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
67
import type { ToolConfig } from '@/tools/types'
78
import { safeUrlPathSegment } from '@/tools/url-path'
@@ -68,10 +69,7 @@ export const rootlyAssignIncidentRoleTool: ToolConfig<
6869
return {
6970
success: false,
7071
output: { incident: {} as RootlyIncidentActionResponse['output']['incident'] },
71-
error:
72-
errorData.errors?.[0]?.detail ||
73-
errorData.errors?.[0]?.title ||
74-
`HTTP ${response.status}: ${response.statusText}`,
72+
error: rootlyErrorMessage(errorData, response),
7573
}
7674
}
7775

‎apps/sim/tools/rootly/create_action_item.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
RootlyCreateActionItemParams,
33
RootlyCreateActionItemResponse,
44
} from '@/tools/rootly/types'
5+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
56
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
67
import type { ToolConfig } from '@/tools/types'
78
import { safeUrlPathSegment } from '@/tools/url-path'
@@ -104,10 +105,7 @@ export const rootlyCreateActionItemTool: ToolConfig<
104105
return {
105106
success: false,
106107
output: { actionItem: {} as RootlyCreateActionItemResponse['output']['actionItem'] },
107-
error:
108-
errorData.errors?.[0]?.detail ||
109-
errorData.errors?.[0]?.title ||
110-
`HTTP ${response.status}: ${response.statusText}`,
108+
error: rootlyErrorMessage(errorData, response),
111109
}
112110
}
113111

‎apps/sim/tools/rootly/create_alert.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RootlyCreateAlertParams, RootlyCreateAlertResponse } from '@/tools/rootly/types'
2+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
23
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
34
import type { ToolConfig } from '@/tools/types'
45

@@ -115,10 +116,7 @@ export const rootlyCreateAlertTool: ToolConfig<RootlyCreateAlertParams, RootlyCr
115116
return {
116117
success: false,
117118
output: { alert: {} as RootlyCreateAlertResponse['output']['alert'] },
118-
error:
119-
errorData.errors?.[0]?.detail ||
120-
errorData.errors?.[0]?.title ||
121-
`HTTP ${response.status}: ${response.statusText}`,
119+
error: rootlyErrorMessage(errorData, response),
122120
}
123121
}
124122

‎apps/sim/tools/rootly/create_incident.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RootlyCreateIncidentParams, RootlyCreateIncidentResponse } from '@/tools/rootly/types'
2+
import { rootlyErrorMessage } from '@/tools/rootly/utils'
23
import { ROOTLY_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
34
import type { ToolConfig } from '@/tools/types'
45

@@ -143,10 +144,7 @@ export const rootlyCreateIncidentTool: ToolConfig<
143144
transformResponse: async (response: Response) => {
144145
if (!response.ok) {
145146
const errorData = await response.json().catch(() => ({}))
146-
const errorMsg =
147-
errorData.errors?.[0]?.detail ||
148-
errorData.errors?.[0]?.title ||
149-
`HTTP ${response.status}: ${response.statusText}`
147+
const errorMsg = rootlyErrorMessage(errorData, response)
150148
return {
151149
success: false,
152150
output: { incident: {} as RootlyCreateIncidentResponse['output']['incident'] },

0 commit comments

Comments
 (0)