Skip to content

Commit 161a2b0

Browse files
committed
fix(vercel,trigger_dev): correct output conditions, surface isSecret
The status output added in this PR was conditioned on 1 of the 7 operations that emit it, and filterOutputsByCondition deletes a failing output rather than leaving it empty -- so delete_alias, whose only response field is status, surfaced nothing real. - narrow state to the two ops that emit it; declare readyState for the two that emit that instead - narrow the deleted condition; delete_alias and delete_deployment never emit it - drop the framework option the API rejects; add the two deployment states the filter accepts - trigger_dev described env var values as plaintext, but the SDK redacts secrets; surface isSecret so a workflow can tell the difference, failing safe when it is absent
1 parent cfa6b2f commit 161a2b0

9 files changed

Lines changed: 275 additions & 22 deletions

File tree

apps/sim/blocks/blocks/trigger_dev.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,11 @@ Return ONLY the valid JSON object - no explanations, no markdown.`,
12261226
description: 'Environment variable or queue name (env var and queue operations)',
12271227
},
12281228
value: { type: 'string', description: 'Value of the environment variable (Get Env Var)' },
1229+
isSecret: {
1230+
type: 'boolean',
1231+
description:
1232+
'Whether the environment variable is a secret, meaning its value is redacted (Get Env Var)',
1233+
},
12291234
success: {
12301235
type: 'boolean',
12311236
description: 'Whether the operation succeeded (env var operations, Complete Waitpoint Token)',

apps/sim/blocks/blocks/vercel.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ export const VercelBlock: BlockConfig = {
339339
{ label: 'Error', id: 'ERROR' },
340340
{ label: 'Queued', id: 'QUEUED' },
341341
{ label: 'Canceled', id: 'CANCELED' },
342+
{ label: 'Initializing', id: 'INITIALIZING' },
343+
{ label: 'Blocked', id: 'BLOCKED' },
342344
],
343345
condition: { field: 'operation', value: 'list_deployments' },
344346
mode: 'advanced',
@@ -607,7 +609,6 @@ export const VercelBlock: BlockConfig = {
607609
{ label: 'SvelteKit', id: 'sveltekit' },
608610
{ label: 'Astro', id: 'astro' },
609611
{ label: 'Gatsby', id: 'gatsby' },
610-
{ label: 'Other', id: 'other' },
611612
],
612613
condition: { field: 'operation', value: ['create_project', 'update_project'] },
613614
mode: 'advanced',
@@ -2197,7 +2198,16 @@ export const VercelBlock: BlockConfig = {
21972198
description: 'Deployment state',
21982199
condition: {
21992200
field: 'operation',
2200-
value: ['get_deployment', 'create_deployment', 'cancel_deployment', 'delete_deployment'],
2201+
value: ['cancel_deployment', 'delete_deployment'],
2202+
},
2203+
},
2204+
readyState: {
2205+
type: 'string',
2206+
description:
2207+
'Deployment ready state: BLOCKED, BUILDING, CANCELED, ERROR, INITIALIZING, QUEUED, or READY',
2208+
condition: {
2209+
field: 'operation',
2210+
value: ['get_deployment', 'create_deployment'],
22012211
},
22022212
},
22032213
deleted: {
@@ -2206,12 +2216,10 @@ export const VercelBlock: BlockConfig = {
22062216
condition: {
22072217
field: 'operation',
22082218
value: [
2209-
'delete_deployment',
22102219
'delete_project',
22112220
'remove_project_domain',
22122221
'delete_domain',
22132222
'delete_dns_record',
2214-
'delete_alias',
22152223
'delete_env_var',
22162224
'delete_webhook',
22172225
'delete_edge_config',
@@ -2233,8 +2241,20 @@ export const VercelBlock: BlockConfig = {
22332241
},
22342242
status: {
22352243
type: 'string',
2236-
description: 'Operation status reported by Vercel',
2237-
condition: { field: 'operation', value: ['update_edge_config_items'] },
2244+
description:
2245+
'Status reported by Vercel: deployment status, check status (registered, running, completed), deletion status, or edge config update status',
2246+
condition: {
2247+
field: 'operation',
2248+
value: [
2249+
'update_edge_config_items',
2250+
'get_deployment',
2251+
'cancel_deployment',
2252+
'delete_alias',
2253+
'create_check',
2254+
'get_check',
2255+
'update_check',
2256+
],
2257+
},
22382258
},
22392259
count: {
22402260
type: 'number',
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it } from 'vitest'
5+
import { TriggerDevBlock } from '@/blocks/blocks/trigger_dev'
6+
import { triggerDevGetEnvVarTool } from '@/tools/trigger_dev/get_env_var'
7+
import { triggerDevListEnvVarsTool } from '@/tools/trigger_dev/list_env_vars'
8+
9+
/** Builds a JSON Response the way the executor hands one to transformResponse. */
10+
function jsonResponse(body: unknown): Response {
11+
return { ok: true, status: 200, json: async () => body } as Response
12+
}
13+
14+
describe('trigger.dev env var secret disambiguation', () => {
15+
it('surfaces isSecret from the retrieve endpoint, which returns it top-level', async () => {
16+
const result = await triggerDevGetEnvVarTool.transformResponse!(
17+
jsonResponse({ name: 'SLACK_API_KEY', value: 'tr_redacted', isSecret: true }),
18+
{} as never
19+
)
20+
21+
expect(result.output).toEqual({
22+
name: 'SLACK_API_KEY',
23+
value: 'tr_redacted',
24+
isSecret: true,
25+
})
26+
})
27+
28+
it('surfaces isSecret false for a non-secret variable', async () => {
29+
const result = await triggerDevGetEnvVarTool.transformResponse!(
30+
jsonResponse({ name: 'LOG_LEVEL', value: 'debug', isSecret: false }),
31+
{} as never
32+
)
33+
34+
expect(result.output.isSecret).toBe(false)
35+
})
36+
37+
it('surfaces isSecret per item from the list endpoint, which returns an array', async () => {
38+
const result = await triggerDevListEnvVarsTool.transformResponse!(
39+
jsonResponse([
40+
{ name: 'SLACK_API_KEY', value: 'redacted', isSecret: true },
41+
{ name: 'LOG_LEVEL', value: 'debug', isSecret: false },
42+
]),
43+
{} as never
44+
)
45+
46+
expect(result.output.variables).toEqual([
47+
{ name: 'SLACK_API_KEY', value: 'redacted', isSecret: true },
48+
{ name: 'LOG_LEVEL', value: 'debug', isSecret: false },
49+
])
50+
})
51+
52+
it('declares isSecret on both tools so it is selectable downstream', () => {
53+
expect(triggerDevGetEnvVarTool.outputs).toHaveProperty('isSecret')
54+
55+
const variables = triggerDevListEnvVarsTool.outputs!.variables as {
56+
items: { properties: Record<string, unknown> }
57+
}
58+
expect(variables.items.properties).toHaveProperty('isSecret')
59+
})
60+
61+
it('treats a missing isSecret as secret, never as a real plaintext value', async () => {
62+
const result = await triggerDevGetEnvVarTool.transformResponse!(
63+
jsonResponse({ name: 'MYSTERY', value: 'something' }),
64+
{} as never
65+
)
66+
67+
expect(result.output.isSecret).toBe(true)
68+
})
69+
})
70+
71+
describe('trigger.dev block env var outputs', () => {
72+
it('declares isSecret alongside its sibling value output', () => {
73+
expect(TriggerDevBlock.outputs).toHaveProperty('value')
74+
expect(TriggerDevBlock.outputs).toHaveProperty('isSecret')
75+
})
76+
})

apps/sim/tools/trigger_dev/get_env_var.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const triggerDevGetEnvVarTool: ToolConfig<
1212
id: 'trigger_dev_get_env_var',
1313
name: 'Trigger.dev Get Env Var',
1414
description:
15-
'Retrieve an environment variable from a Trigger.dev project environment. The value is returned in plaintext and will appear in workflow outputs and run history.',
15+
'Retrieve an environment variable from a Trigger.dev project environment. A secret variable is returned redacted; a non-secret value is returned in plaintext and will appear in workflow outputs and run history.',
1616
version: '1.0.0',
1717

1818
params: {
@@ -48,13 +48,22 @@ export const triggerDevGetEnvVarTool: ToolConfig<
4848
headers: (params) => buildTriggerDevHeaders(params.apiKey),
4949
},
5050

51+
/**
52+
* The retrieve endpoint is typed `EnvironmentVariableWithSecret` in
53+
* `@trigger.dev/core`, which returns `isSecret` at the top level alongside
54+
* `name` and `value`. The field is required there, so the fallback never
55+
* fires; it defaults to `true` because assuming a value is secret is the
56+
* safe direction — a caller must never treat a possibly-redacted value as
57+
* the real one.
58+
*/
5159
transformResponse: async (response) => {
5260
const data = await response.json()
5361
return {
5462
success: true,
5563
output: {
5664
name: data.name,
5765
value: data.value,
66+
isSecret: data.isSecret ?? true,
5867
},
5968
}
6069
},
@@ -64,7 +73,12 @@ export const triggerDevGetEnvVarTool: ToolConfig<
6473
value: {
6574
type: 'string',
6675
description:
67-
'Plaintext value of the environment variable; appears in workflow outputs and run history',
76+
'Value of the environment variable. Secret variables come back redacted, not as the real value; non-secret values are plaintext and appear in workflow outputs and run history',
77+
},
78+
isSecret: {
79+
type: 'boolean',
80+
description:
81+
"Whether the variable is a secret. A secret variable's value comes back redacted, so branch on this before treating the value as real",
6882
},
6983
},
7084
}

apps/sim/tools/trigger_dev/list_env_vars.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const triggerDevListEnvVarsTool: ToolConfig<
1212
id: 'trigger_dev_list_env_vars',
1313
name: 'Trigger.dev List Env Vars',
1414
description:
15-
'List the environment variables of a Trigger.dev project environment. Values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully.',
15+
'List the environment variables of a Trigger.dev project environment. Secret variables are returned redacted; non-secret values are returned in plaintext and will appear in workflow outputs and run history — scope this operation carefully.',
1616
version: '1.0.0',
1717

1818
params: {
@@ -42,6 +42,14 @@ export const triggerDevListEnvVarsTool: ToolConfig<
4242
headers: (params) => buildTriggerDevHeaders(params.apiKey),
4343
},
4444

45+
/**
46+
* The list endpoint is typed `z.array(EnvironmentVariableWithSecret)` in
47+
* `@trigger.dev/core`, so `isSecret` arrives per item rather than at the top
48+
* level. The field is required there, so the fallback never fires; it
49+
* defaults to `true` because assuming a value is secret is the safe
50+
* direction — a caller must never treat a possibly-redacted value as the
51+
* real one.
52+
*/
4553
transformResponse: async (response) => {
4654
const data = await response.json()
4755
const variables = Array.isArray(data) ? data : []
@@ -51,6 +59,7 @@ export const triggerDevListEnvVarsTool: ToolConfig<
5159
variables: variables.map((variable) => ({
5260
name: variable.name,
5361
value: variable.value,
62+
isSecret: variable.isSecret ?? true,
5463
})),
5564
},
5665
}
@@ -68,7 +77,12 @@ export const triggerDevListEnvVarsTool: ToolConfig<
6877
value: {
6978
type: 'string',
7079
description:
71-
'Plaintext value of the environment variable; appears in workflow outputs and run history',
80+
'Value of the environment variable. Secret variables come back redacted, not as the real value; non-secret values are plaintext and appear in workflow outputs and run history',
81+
},
82+
isSecret: {
83+
type: 'boolean',
84+
description:
85+
"Whether the variable is a secret. A secret variable's value comes back redacted, so branch on this before treating the value as real",
7286
},
7387
},
7488
},

apps/sim/tools/trigger_dev/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export interface TriggerDevQueue {
221221
export interface TriggerDevEnvVar {
222222
name: string
223223
value: string
224+
isSecret: boolean
224225
}
225226

226227
/** Raw run result object returned by the run result and batch results endpoints */

0 commit comments

Comments
 (0)