You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2db84dd
Browse filesBrowse the repository at this point in the historyBrowse files
improvement(workflow-code): say why a Function's code prints as stored() and how to make it editable (#10730)
A code field (a Function's code) holding a detected credential prints whole as stored(), and its W_LITERAL_SECRET hint said to interpolate env.NAME in a t template, which does not apply to code. The finding now says the whole code is hidden, and that storing the key as a workspace secret read as {{NAME}} ($env.NAME in a JavaScript code file) lets the next get print it. Print, compile and both tool paths carry the field's value kind. The CLI appends the sim secrets set command to that hint.
Copy file name to clipboardExpand all lines: apps/docs/content/docs/workflows/code/diagnostics.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ Reading and writing `workflow.ts`.
82
82
|`W_VALUE_KIND`| A value whose JSON type differs from the field's. |
83
83
|`W_OUT_OF_RANGE`| A literal slider value outside the catalog `min`/`max`, off its `step`, or fractional where it takes whole numbers; kept as written, and the executor forwards it unclamped. |
84
84
|`W_TABLE_FILTER_SHAPE`| A literal table filter the runtime refuses: the legacy `$` operator grammar, or predicate and builder rows mixed. |
85
-
|`W_LITERAL_SECRET`| A password field (an API key, a token) holding literal text instead of an env reference, or any field or workflow variable holding a detected credential (a token format, an `Authorization` header, a credential-named property or query parameter); get prints it as `stored()`. A value Sim minted at creation (a webhook token) is not reported. For a literal token in a credential field, the hint says `credential('<key>')`. |
85
+
|`W_LITERAL_SECRET`| A password field (an API key, a token) holding literal text instead of an env reference, or any field or workflow variable holding a detected credential (a token format, an `Authorization` header, a credential-named property or query parameter); get prints it as `stored()`. A value Sim minted at creation (a webhook token) is not reported. For a literal token in a credential field, the hint says `credential('<key>')`. On a code field (a Function's code) get hides the whole code, and the hint says how to make it editable: store the key as a workspace secret and read it in the code as `{{NAME}}` (`$env.NAME` in a JavaScript code file). |
86
86
|`W_SUBFLOW_COUNT`| A loop or parallel count, or a parallel batch size, the runtime replaces or clamps. |
87
87
|`W_UNKNOWN_OUTPUT_PATH`| A ref path the block's outputs do not have; the hint has a did-you-mean or lists the outputs. |
88
88
|`W_OUTPUT_PATH_UNDECLARED`| A path the block does not declare that the run still accepts: an undeclared `inputFormat` input, or `x.error` with no error edge. Never refused. |
hint: `Store the value as a secret, never in the file: \`sim secrets set NAME --scope workspace --value @-\` with the value piped from a file or variable, never typed into the command, then write ${param}: env.NAME (import env from '@sim/workflow-sdk'). A check passes a name set since the get; the apply checks it against the workspace.`,
269
+
hint: `Store the value as a secret, never in the file: ${SECRETS_SET}, then write ${param}: env.NAME (import env from '@sim/workflow-sdk'). A check passes a name set since the get; the apply checks it against the workspace.`,
Copy file name to clipboardExpand all lines: packages/workflow-code/src/compile/SYNTAX.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,9 @@ value `CompileInput.stored` (the stored workflow the file continues) holds for t
189
189
type and param, a pair's members and mode included. A new block, another type or an empty field is
190
190
`E_STORED_VALUE_MISSING`; inside a value it is `E_UNSUPPORTED_SYNTAX`. A variable's
191
191
`value: stored()` compiles to the stored workflow's variable of the same key, and is
192
-
`E_STORED_VALUE_MISSING` when there is none.
192
+
`E_STORED_VALUE_MISSING` when there is none. A code field (a Function's code) holding a detected credential prints
193
+
whole as `stored()`, so source can neither show nor edit it until the key moves into a workspace
194
+
secret the code reads as `{{NAME}}`; its `W_LITERAL_SECRET` says so.
193
195
194
196
A tool's `stored()` takes the value of the stored tool it continues, matched by identity: the one
195
197
stored tool of the same type and operation whose params agree with every param the source writes.
@@ -465,7 +467,7 @@ Errors refuse the whole apply. Warnings are saved as written; info is informatio
465
467
|`W_VALUE_KIND`| A value whose JSON type differs from the field's. |
466
468
|`W_OUT_OF_RANGE`| A literal slider value outside the catalog `min`/`max`, off its `step`, or fractional where it takes whole numbers; kept as written, and the executor forwards it unclamped. |
467
469
|`W_TABLE_FILTER_SHAPE`| A literal table filter the runtime refuses: the legacy `$` operator grammar, or predicate and builder rows mixed. |
468
-
|`W_LITERAL_SECRET`| A password field (an API key, a token) holding literal text instead of an env reference, or any field or workflow variable holding a detected credential (a token format, an `Authorization` header, a credential-named property or query parameter); get prints it as `stored()`. A value Sim minted at creation (a webhook token) is not reported. For a literal token in a credential field, the hint says `credential('<key>')`. |
470
+
|`W_LITERAL_SECRET`| A password field (an API key, a token) holding literal text instead of an env reference, or any field or workflow variable holding a detected credential (a token format, an `Authorization` header, a credential-named property or query parameter); get prints it as `stored()`. A value Sim minted at creation (a webhook token) is not reported. For a literal token in a credential field, the hint says `credential('<key>')`. On a code field (a Function's code) get hides the whole code, and the hint says how to make it editable: store the key as a workspace secret and read it in the code as `{{NAME}}` (`$env.NAME` in a JavaScript code file). |
469
471
|`W_SUBFLOW_COUNT`| A loop or parallel count, or a parallel batch size, the runtime replaces or clamps. |
470
472
|`W_UNKNOWN_OUTPUT_PATH`| A ref path the block's outputs do not have; the hint has a did-you-mean or lists the outputs. |
471
473
|`W_OUTPUT_PATH_UNDECLARED`| A path the block does not declare that the run still accepts: an undeclared `inputFormat` input, or `x.error` with no error edge. Never refused. |
/** `text` with every reference and `{{ENV}}` token blanked to one space. */
@@ -204,15 +205,18 @@ export function holdsSecret(field: { password?: boolean } | undefined, value: Va
204
205
}
205
206
206
207
/** The traits of the field a `W_LITERAL_SECRET` finding is about. */
207
-
interfaceSecretField{
208
+
exportinterfaceSecretField{
208
209
password?: boolean
209
210
/** Set on a resource selector; a `credential` one takes `credential('<key>')`. */
210
211
resourceKind?: ResourceKind
212
+
/** `code` on a code body (a Function's code, among others), which `stored()` hides whole. */
213
+
valueKind?: CatalogValueKind
211
214
}
212
215
213
216
/**
214
217
* The message and hint of `W_LITERAL_SECRET` for the param written as `name`: a password field's,
215
-
* a credential selector holding a literal token, or a credential detected in another field.
218
+
* a credential selector holding a literal token, a code body (hidden whole, so the hint says how
219
+
* to make it editable), or a credential detected in another field.
216
220
*/
217
221
exportfunctionliteralSecretFinding(
218
222
name: string,
@@ -230,6 +234,12 @@ export function literalSecretFinding(
230
234
hint: `Save the token as a workspace credential and write ${name}: credential('<key>'), so the token never sits in the workflow.`,
231
235
}
232
236
}
237
+
if(field.valueKind==='code'){
238
+
return{
239
+
message: `${name} holds what looks like a literal credential, so get prints the whole code as stored(): source can neither show nor edit it.`,
240
+
hint: 'Store the key as a workspace secret and read it in the code as {{NAME}} ($env.NAME in a JavaScript code file), then get again and the code prints. Code printed as stored() is changed where it can be seen, by someone who can open the block: code written in its place replaces code you cannot see.',
241
+
}
242
+
}
233
243
return{
234
244
message: `${name} holds what looks like a literal credential; get prints it as stored() so it never lands in a file.`,
235
245
hint: 'Store the credential as a workspace or personal env variable and interpolate env.NAME into the value in a t template, so the key never sits in the workflow.',
0 commit comments