fix: #2359 render template tokens inside array-valued config - #2382
Open
bongbongcrypto wants to merge 1 commit into
Open
fix: #2359 render template tokens inside array-valued config#2382bongbongcrypto wants to merge 1 commit into
bongbongcrypto wants to merge 1 commit into
Conversation
processTemplates recursed into plain objects and excluded arrays, so a token stored inside an array in an action config was copied verbatim. The scan that runs immediately after, scanForLeftoverLiterals, does walk arrays, found the token, and aborted the run with a message naming a reference that was correct. The container it sat in decided the outcome. The renderer now recurses into arrays. The string, array and object cases go through one helper, renderTemplateValue, so the renderer and the scan agree on what a container is: a string is rendered, an array element by element, an object through processTemplates, anything else passed through as it is. The doc comment that said "supports array paths like data.recipes[0]" is rewritten; that was about an index inside a reference, not array-valued config, and read quickly it said the opposite of what the code did. Per the amendment on the issue, web3/read-contract's functionArgs now accepts string | unknown[], as web3/query-transactions already does for the same widget. Without that, the renderer's change would have turned the guard's message into an uncaught TypeError: the step declared the string only and called .trim() on it. A native array is taken as it is; a string is parsed as JSON; an empty string still means no arguments. Nothing else moves. scanForLeftoverLiterals is correct as written. condition, conditionConfig, dbQuery and code are lifted out before the renderer runs, so array recursion cannot reach the rules array under conditionConfig. processCodeTemplates and extractTemplateParameters take a string, not a container, so no array case exists for them. valueContainsTemplate and walkNodeConfigStrings are the create-time and PATCH-time counterparts the issue thread noted and are left for their own change. Array recursion has no depth cap, which matches the object recursion it sits beside; the scan is what is capped. Tests: a token as an array element, inside an object inside an array, and inside an array inside an object inside an array; non-string elements and order preserved; an unresolved token inside an array still recorded and still closing the gate; scalar and nested-object rendering unchanged; and the three step inputs that accept a native array end to end, calls on web3/batch-write-contract, functionArgs on web3/query-transactions and payouts on tempo/batch-payout. read-contract-core: the array shape produces the same contract call as its JSON-string shape, a non-array JSON string is still refused, and an empty string still means no arguments. Against staging's own executor and step, exactly the nine new cases fail and the TypeError reproduces; with this change 95 of 95 pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
About the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2359
What this changes
processTemplatesinlib/workflow/executor/executor.workflow.tsnow recurses into arrays. The string, array and object cases go through one helper,renderTemplateValue, so the renderer andscanForLeftoverLiteralsagree on what a container is. The doc comment that said "supports array paths likedata.recipes[0]" is rewritten, since that was about an index inside a reference rather than array-valued config.Per the amendment on the issue,
web3/read-contract'sfunctionArgsacceptsstring | unknown[], asweb3/query-transactionsalready does for the same widget. A native array is taken as it is, a string is parsed as JSON, an empty string still means no arguments. Without this the renderer's change would have turned the guard's message intoTypeError: functionArgs.trim is not a function.What does not change
scanForLeftoverLiterals: correct as written.condition,conditionConfig,dbQueryandcodeare lifted out before the renderer runs, so array recursion cannot reach the rules array underconditionConfig.processCodeTemplatesandextractTemplateParameterstake a string, not a container; no array case exists for them.valueContainsTemplateandwalkNodeConfigStrings, the create-time and PATCH-time counterparts noted on the issue, are left for their own change.Tests
tests/unit/template-fail-closed.test.ts: a token as an array element, inside an object inside an array, and inside an array inside an object inside an array; non-string elements and order preserved; an unresolved token inside an array still recorded and still closing the gate; scalar and nested-object rendering unchanged; and the three step inputs that accept a native array end to end (callsonweb3/batch-write-contract,functionArgsonweb3/query-transactions,payoutsontempo/batch-payout).tests/unit/read-contract-core.test.ts: the array shape produces the same contract call as its JSON-string shape; a non-array JSON string is still refused; an empty string still means no arguments.Run against
staging's own executor and step with the new tests in place, exactly the nine new cases fail and the TypeError reproduces. With this change, 95 of 95 pass across the two files.biome checkis clean on the four changed files.I could not run the full
tests/unitsuite ortsgolocally this round; those are on the CI jobs pending approval.🤖 Generated with Claude Code