Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(executor): never suggest a digit-only object key as a reference path
  • Loading branch information
waleedlatif1 committed Sep 30, 2026
commit 97c4917e9dc4b362a02cbc5e10b80a9479d3b386
23 changes: 13 additions & 10 deletions apps/sim/executor/variables/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1048,17 +1048,20 @@ describe('VariableResolver function block inputs', () => {
)
})

it('omits a field reference that a key cannot be written as', async () => {
await expect(
resolveAgainstProducer(
'javascript',
{ result: { 'report.txt': largeRef(10.5 * 1024 * 1024) } },
'return <Producer.result>'
it.each(['report.txt', '0'])(
'omits a field reference that the key %s cannot be written as',
async (key) => {
await expect(
resolveAgainstProducer(
'javascript',
{ result: { [key]: largeRef(10.5 * 1024 * 1024) } },
'return <Producer.result>'
)
).rejects.toThrow(
'<Producer.result> contains a 10.5 MB value. Reference the field you need directly.'
)
).rejects.toThrow(
'<Producer.result> contains a 10.5 MB value. Reference the field you need directly.'
)
})
}
)
})

it('breaks JavaScript string literals around quoted block references', async () => {
Expand Down
7 changes: 5 additions & 2 deletions apps/sim/executor/variables/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ interface LocatedLargeValue {
size: number
}

/** An object key a reference can reach with `.key`: no whitespace, path, or operator characters. */
const REFERENCEABLE_KEY = /^[^\s.[\]+*/=<>!&|]+$/
/**
* An object key a reference can reach with `.key`: no whitespace, path, or operator characters,
* and not digits alone, which path navigation reads as an array index.
*/
const REFERENCEABLE_KEY = /^(?!\d+$)[^\s.[\]+*/=<>!&|]+$/

/** How to use a large value in a runtime that cannot load one on demand. */
const LARGE_VALUE_RUNTIME_HINT = 'Select a smaller field, or read it in JavaScript without imports.'
Expand Down
Loading