Skip to content

Commit 4a1e26c

Browse files
committed
fix(incidentio): stop the block offering rejected enum values and declare every actor branch
1 parent c183275 commit 4a1e26c

8 files changed

Lines changed: 137 additions & 9 deletions

File tree

apps/docs/content/docs/integrations/incidentio.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ List all escalation policies in incident.io
782782
|`id` | string | The escalation ID |
783783
|`title` | string | The escalation title |
784784
|`status` | string | The current escalation status |
785+
|`description` | string | Additional detail provided with this escalation |
786+
|`priority` | object | The escalation priority |
787+
|`name` | string | Priority name |
785788
|`created_at` | string | When the escalation was created |
786789
|`updated_at` | string | When the escalation was last updated |
787790
| `pagination_meta` | object | Pagination metadata |
@@ -810,6 +813,9 @@ Create a new escalation policy in incident.io
810813
|`id` | string | The escalation ID |
811814
|`title` | string | The escalation title |
812815
|`status` | string | The current escalation status |
816+
|`description` | string | Additional detail provided with this escalation |
817+
|`priority` | object | The escalation priority |
818+
|`name` | string | Priority name |
813819
|`created_at` | string | When the escalation was created |
814820
|`updated_at` | string | When the escalation was last updated |
815821

@@ -832,6 +838,9 @@ Get details of a specific escalation policy in incident.io
832838
|`id` | string | The escalation ID |
833839
|`title` | string | The escalation title |
834840
|`status` | string | The current escalation status |
841+
|`description` | string | Additional detail provided with this escalation |
842+
|`priority` | object | The escalation priority |
843+
|`name` | string | Priority name |
835844
|`created_at` | string | When the escalation was created |
836845
|`updated_at` | string | When the escalation was last updated |
837846

@@ -1208,10 +1217,19 @@ List all updates for a specific incident in incident.io
12081217
|`name` | string | Status name |
12091218
|`category` | string | Status category |
12101219
|`updater` | object | Actor who created the update |
1211-
|`user` | object | User who created the update |
1220+
|`user` | object | Set when a user made the update |
12121221
|`id` | string | User ID |
12131222
|`name` | string | User name |
12141223
|`email` | string | User email |
1224+
|`api_key` | object | Set when an API key made the update |
1225+
|`id` | string | API key ID |
1226+
|`name` | string | API key name |
1227+
|`workflow` | object | Set when a workflow made the update |
1228+
|`id` | string | Workflow ID |
1229+
|`name` | string | Workflow name |
1230+
|`alert` | object | Set when an alert made the update |
1231+
|`id` | string | Alert ID |
1232+
|`title` | string | Alert title |
12151233
|`created_at` | string | When the update was created |
12161234
| `pagination_meta` | object | Pagination information |
12171235
|`after` | string | Cursor for next page |

apps/sim/blocks/blocks/incidentio.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,6 @@ Return ONLY the title - no explanations.`,
701701
options: [
702702
{ label: 'Newly Created', id: 'newly_created' },
703703
{ label: 'Newly Created and Active', id: 'newly_created_and_active' },
704-
{ label: 'Active', id: 'active' },
705-
{ label: 'All', id: 'all' },
706704
],
707705
value: () => 'newly_created',
708706
condition: {

apps/sim/tools/generated/tool-outputs.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/incidentio/escalations_create.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ export const escalationsCreateTool: ToolConfig<
9292
id: { type: 'string', description: 'The escalation ID' },
9393
title: { type: 'string', description: 'The escalation title' },
9494
status: { type: 'string', description: 'The current escalation status' },
95+
description: {
96+
type: 'string',
97+
description: 'Additional detail provided with this escalation',
98+
},
99+
priority: {
100+
type: 'object',
101+
description: 'The escalation priority',
102+
properties: { name: { type: 'string', description: 'Priority name' } },
103+
},
95104
created_at: { type: 'string', description: 'When the escalation was created' },
96105
updated_at: { type: 'string', description: 'When the escalation was last updated' },
97106
},

apps/sim/tools/incidentio/escalations_list.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ export const escalationsListTool: ToolConfig<
7575
id: { type: 'string', description: 'The escalation ID' },
7676
title: { type: 'string', description: 'The escalation title' },
7777
status: { type: 'string', description: 'The current escalation status' },
78+
description: {
79+
type: 'string',
80+
description: 'Additional detail provided with this escalation',
81+
},
82+
priority: {
83+
type: 'object',
84+
description: 'The escalation priority',
85+
properties: { name: { type: 'string', description: 'Priority name' } },
86+
},
7887
created_at: { type: 'string', description: 'When the escalation was created' },
7988
updated_at: {
8089
type: 'string',

apps/sim/tools/incidentio/escalations_show.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ export const escalationsShowTool: ToolConfig<
5656
id: { type: 'string', description: 'The escalation ID' },
5757
title: { type: 'string', description: 'The escalation title' },
5858
status: { type: 'string', description: 'The current escalation status' },
59+
description: {
60+
type: 'string',
61+
description: 'Additional detail provided with this escalation',
62+
},
63+
priority: {
64+
type: 'object',
65+
description: 'The escalation priority',
66+
properties: { name: { type: 'string', description: 'Priority name' } },
67+
},
5968
created_at: { type: 'string', description: 'When the escalation was created' },
6069
updated_at: { type: 'string', description: 'When the escalation was last updated' },
6170
},

apps/sim/tools/incidentio/incident_updates_list.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,41 @@ export const incidentUpdatesListTool: ToolConfig<
118118
properties: {
119119
user: {
120120
type: 'object',
121-
description: 'User who created the update',
121+
description: 'Set when a user made the update',
122122
optional: true,
123123
properties: {
124124
id: { type: 'string', description: 'User ID' },
125125
name: { type: 'string', description: 'User name' },
126126
email: { type: 'string', description: 'User email', optional: true },
127127
},
128128
},
129+
api_key: {
130+
type: 'object',
131+
description: 'Set when an API key made the update',
132+
optional: true,
133+
properties: {
134+
id: { type: 'string', description: 'API key ID' },
135+
name: { type: 'string', description: 'API key name' },
136+
},
137+
},
138+
workflow: {
139+
type: 'object',
140+
description: 'Set when a workflow made the update',
141+
optional: true,
142+
properties: {
143+
id: { type: 'string', description: 'Workflow ID' },
144+
name: { type: 'string', description: 'Workflow name' },
145+
},
146+
},
147+
alert: {
148+
type: 'object',
149+
description: 'Set when an alert made the update',
150+
optional: true,
151+
properties: {
152+
id: { type: 'string', description: 'Alert ID' },
153+
title: { type: 'string', description: 'Alert title' },
154+
},
155+
},
129156
},
130157
},
131158
created_at: { type: 'string', description: 'When the update was created' },

apps/sim/tools/incidentio/output_drift.test.ts

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @vitest-environment node
33
*/
44
import { describe, expect, it } from 'vitest'
5+
import { IncidentioBlock } from '@/blocks/blocks/incidentio'
56
import { customFieldsCreateTool } from '@/tools/incidentio/custom_fields_create'
67
import { escalationsCreateTool } from '@/tools/incidentio/escalations_create'
78
import { escalationsListTool } from '@/tools/incidentio/escalations_list'
@@ -143,7 +144,7 @@ describe('incident_updates new_incident_status output', () => {
143144
'incident_updates',
144145
'updater',
145146
])
146-
expect(updaterFields).toEqual(['user'])
147+
expect(updaterFields.sort()).toEqual(['alert', 'api_key', 'user', 'workflow'])
147148
expect(
148149
declaredPropertyNames(incidentUpdatesListTool.outputs, [
149150
'incident_updates',
@@ -184,11 +185,13 @@ const SPEC_ESCALATION = {
184185

185186
describe('escalation title output', () => {
186187
it('declares title and status instead of name', () => {
187-
expect(declaredPropertyNames(escalationsListTool.outputs, ['escalations'])).toEqual([
188+
expect(declaredPropertyNames(escalationsListTool.outputs, ['escalations']).sort()).toEqual([
189+
'created_at',
190+
'description',
188191
'id',
189-
'title',
192+
'priority',
190193
'status',
191-
'created_at',
194+
'title',
192195
'updated_at',
193196
])
194197
for (const tool of [escalationsShowTool, escalationsCreateTool]) {
@@ -251,3 +254,58 @@ describe('custom_fields_create field_type description', () => {
251254
}
252255
})
253256
})
257+
258+
/**
259+
* `WorkflowsCreate/UpdateWorkflowPayloadV2.runs_on_incidents` accepts exactly
260+
* `newly_created` and `newly_created_and_active`. The block previously offered
261+
* `active` and `all` as well, so a user could pick a value the API rejects with
262+
* a 422 — the tool-side description alone does not close that path.
263+
*/
264+
describe('the block only offers runs_on_incidents values the API accepts', () => {
265+
const SPEC_ENUM = ['newly_created', 'newly_created_and_active']
266+
267+
it('offers exactly the spec enum', () => {
268+
const sub = IncidentioBlock.subBlocks.find((s) => s.id === 'runs_on_incidents')
269+
expect(sub).toBeDefined()
270+
const ids = (sub!.options as Array<{ id: string }>).map((o) => o.id)
271+
expect(ids).toEqual(SPEC_ENUM)
272+
})
273+
274+
it('defaults to a value the API accepts', () => {
275+
const sub = IncidentioBlock.subBlocks.find((s) => s.id === 'runs_on_incidents')
276+
expect(SPEC_ENUM).toContain((sub as { value: () => string }).value())
277+
})
278+
})
279+
280+
/**
281+
* `updater` is an `ActorV2`, a four-branch union. Declaring only `user` meant an
282+
* update made by an API key, workflow or alert had no reachable actor fields.
283+
*/
284+
describe('updater declares every ActorV2 branch', () => {
285+
it('covers user, api_key, workflow and alert', () => {
286+
const updater = (
287+
incidentUpdatesListTool.outputs?.incident_updates as {
288+
items?: { properties?: Record<string, { properties?: Record<string, unknown> }> }
289+
}
290+
)?.items?.properties?.updater
291+
expect(Object.keys(updater?.properties ?? {}).sort()).toEqual([
292+
'alert',
293+
'api_key',
294+
'user',
295+
'workflow',
296+
])
297+
})
298+
})
299+
300+
/** `description` and `priority` are both in EscalationV2's required set. */
301+
describe('escalations declare the fields the spec marks required', () => {
302+
it.each([
303+
['escalations_create', escalationsCreateTool],
304+
['escalations_show', escalationsShowTool],
305+
['escalations_list', escalationsListTool],
306+
])('%s', (_name, tool) => {
307+
const declared = JSON.stringify(tool.outputs)
308+
expect(declared).toContain('description')
309+
expect(declared).toContain('priority')
310+
})
311+
})

0 commit comments

Comments
 (0)