test: pin more evaluation paths from parameters to resources - #224
Merged
Conversation
Second batch alongside resourceclosure: validation blocks, for expressions, a splat in a tag, a count = 0 resource behind try(), a resource whose for_each is driven by a parameter, a computed attribute, a two-level module chain, multi-hop locals, and a template whose only parameter lives in a submodule.
Emyrk
marked this pull request as ready for review
September 11, 2026 13:54
f0ssel
approved these changes
Sep 11, 2026
PushTheLimit
added a commit
to PushTheLimit/preview
that referenced
this pull request
Sep 11, 2026
Preview evaluates the entire Terraform module graph on every call, even though rendering a workspace form only needs coder_parameter, coder_workspace_preset and coder_workspace_tags (and what they reference). The resources a workspace would create cannot feed those blocks, so evaluating them is wasted work that dominates request latency on large templates. Pass OptionWithResourceClosure with the three target block types so the parser drops root-module resources that nothing in that closure references. On a real template this cuts EvaluateAll from ~2s to ~0.16s (~12x) with byte-identical parameters, presets and tags. Uses the OptionWithResourceClosure addition merged in coder/trivy#74; the trivy replace points at that merged commit. Correctness is guarded by the resource closure test corpus already in main (coder#223, coder#224).
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.
Follow-up to #223. Pins more of the evaluation paths a parameter, preset, or tag can take to reach a
resource, ahead of #221. All pass onmain, and on #221 with the trivy pin at coder/trivy#74's current head (fc995ac).testdata/resourceclosure2:validationblock text and regex from a resource (asserted with a failing input),[for ...]and{for ...}overcountandfor_eachresources, a splat directly in a tag, acount = 0resource behindtry(), a resource whosefor_eachis driven by a parameter value and is read by a tag, a computed attribute (stays unknown), a two-levelmodule.outer->module.innerchain, and three-hop locals.testdata/resourceclosuresubmod: the only parameter is in a submodule and reads a root resource through a module input; the root has no target block at all.Prepared with Coder Agents assistance.