Summary
ResolveParameters only narrows the stored parameter set when the render is
complete, and decides completeness from a single signal
(coderd/dynamicparameters/resolver.go):
if transition == database.WorkspaceTransitionStart && !incompleteRender(diags) {
// delete stored values for parameters missing from this render
}
incompleteRender returns true when preview emits module_not_loaded. preview
infers that diagnostic rather than detecting it, so the signal is wrong in
both directions.
Why this matters
False positive. preview reports modules as not loaded when they loaded
correctly (coder/preview#228). On main that permanently pins affected
templates into "incomplete render", so values for parameters the template
genuinely removed are never cleaned up. Reproduced on main with the vendored
preview: four spurious diagnostics on a template whose parameters all render.
False negative. The diagnostic is inferred from whether any parsed block
references each module block. A module that loads but contributes no blocks, or
a future change in the inference, produces no diagnostic while parameters are
still missing from the render. The guard then deletes stored values, which is
the failure mode #29099 described.
coderd does not need to infer any of this. It knows whether it handed the
renderer the module files: template_version_terraform_values.cached_module_files
is what render.go overlays at .terraform/modules. A NULL archive is not on
its own evidence of anything, because provisionerd only archives remotely
sourced modules, so a template whose modules are all local stores nothing and
still renders completely (GetModulesArchive returns zero bytes for it). The
cached plan supplies the missing half: configuration.root_module.module_calls
lists each call and its source, at every depth.
Proposed fix
Decide completeness from coderd's own state: a version that depends on a
remotely sourced module but has no cached module archive cannot be rendered
completely. Keep the preview diagnostic as a fallback so behaviour is never
weaker than today. PR linked below.
Related
Filed by Coder Agents on behalf of @angrycub.
Summary
ResolveParametersonly narrows the stored parameter set when the render iscomplete, and decides completeness from a single signal
(
coderd/dynamicparameters/resolver.go):incompleteRenderreturns true when preview emitsmodule_not_loaded. previewinfers that diagnostic rather than detecting it, so the signal is wrong in
both directions.
Why this matters
False positive. preview reports modules as not loaded when they loaded
correctly (coder/preview#228). On
mainthat permanently pins affectedtemplates into "incomplete render", so values for parameters the template
genuinely removed are never cleaned up. Reproduced on
mainwith the vendoredpreview: four spurious diagnostics on a template whose parameters all render.
False negative. The diagnostic is inferred from whether any parsed block
references each module block. A module that loads but contributes no blocks, or
a future change in the inference, produces no diagnostic while parameters are
still missing from the render. The guard then deletes stored values, which is
the failure mode #29099 described.
coderd does not need to infer any of this. It knows whether it handed the
renderer the module files:
template_version_terraform_values.cached_module_filesis what
render.gooverlays at.terraform/modules. A NULL archive is not onits own evidence of anything, because provisionerd only archives remotely
sourced modules, so a template whose modules are all local stores nothing and
still renders completely (
GetModulesArchivereturns zero bytes for it). Thecached plan supplies the missing half:
configuration.root_module.module_callslists each call and its source, at every depth.
Proposed fix
Decide completeness from coderd's own state: a version that depends on a
remotely sourced module but has no cached module archive cannot be rendered
completely. Keep the preview diagnostic as a fallback so behaviour is never
weaker than today. PR linked below.
Related
about not depending on that inference for data safety.
discarded (
provision.goTODO), with no UI or API surface. Same class ofproblem, tracked separately.
Filed by Coder Agents on behalf of @angrycub.