Closes#29099 ([ENG-3324](https://linear.app/codercom/issue/ENG-3324)).
Follow-up to #29102, which stopped the loss propagating through stop
builds but left start builds truncating.
## What this does
A render carrying a `module_not_loaded` diagnostic could not see the
whole template, so a parameter's absence from it is not evidence the
template stopped declaring that parameter. Keep the unmatched values
instead of deleting them.
## Why preserve rather than fail
provisionerd resolves modules itself, so only coderd's render is
degraded. Keeping the value produces a correct apply and the workspace
keeps building. Failing the build would turn silent data loss into an
inability to start every workspace on an affected template version.
A complete render is still authoritative and still narrows the set, so
unrelated warnings and legitimate parameter removals behave exactly as
before.
## Tests
- `TestResolveParameters/IncompleteRender`: complete render drops,
`module_not_loaded` preserves previous and build values, unrelated
warning drops.
- `TestDynamicParametersModuleCachePurged` now continues into the start
build. On `main` it fails with `start build must not drop the module
parameter`.
<details>
<summary>Notes for the reviewer</summary>
### Detection
`preview` tags the warning with `types.DiagnosticCode(diag,
types.DiagnosticModuleNotLoaded)`, so the check is
`previewtypes.ExtractDiagnosticExtra(diag).Code ==
previewtypes.DiagnosticModuleNotLoaded` over the second render's
diagnostics. Adding future completeness codes is a one-line change in
`incompleteRender`.
### Departure from the issue's sketch
The issue proposed also gating on `v.Source != sourceDefault`, to keep
discarding values that only ever came from a default. That check cannot
fire: `sourceDefault` is only assigned to parameters present in the
render output, so an unmatched value is never default-sourced. A default
stored by an earlier build arrives as `sourcePrevious` and is
indistinguishable from user input at this layer. The condition is
omitted rather than left in as dead code.
### Not covered
Nothing surfaces the degraded render to the operator. `wsbuilder` has no
logger, and `render.go` still discards preview's diagnostics (`Logger:
slog.New(slog.DiscardHandler)`). That is the follow-up work listed in
the issue.
</details>
---
🤖 Authored by Coder Agents on behalf of @Emyrk.
Fixes part of #29099
([ENG-3324](https://linear.app/codercom/issue/ENG-3324)).
## What this does
Only a start build may narrow the stored set. A stop or delete build
does not change which parameters a workspace has.
## Why
A stop or delete build re-resolves the workspace parameters and deletes
every stored value the render did not return.
- When a template version's `cached_module_files` is NULL the renderer
cannot load modules, and the parameters are dropped. Any `restart` or
`coder update`, uses the broken version for `stop` and all parameters
are removed before the fixed `start`.
- This can happen on any broken template version
## Scope
This does not fix a start build that resolves against a version with a
NULL module cache, which still truncates. That is the completeness-aware
discard loop described in the issue, and it lands separately.
## Tests
- `TestResolveParameters/UnmatchedValues` covers all three transitions
at the resolver level.
- `TestDynamicParametersModuleCachePurged` is an end-to-end regression
test: create a workspace with a module declared parameter, remove the
module cache, stop, and assert the value survives. It fails on `main`.
<details>
<summary>Implementation plan</summary>
### Problem
`dynamicparameters.ResolveParameters` ends with an unconditional discard
loop (`coderd/dynamicparameters/resolver.go`) that deletes every stored
value whose parameter is absent from the render output. With a NULL
module cache the render is incomplete, `preview` reports
`module_not_loaded` at warning severity, and the reduced parameter set
is treated as authoritative.
`wsbuilder.getParameters()` is transition-agnostic, so a stop build
persists that truncated set. `cli/update.go` stops first against the
workspace's current version, then starts against the active version, and
the start build reads the truncated set via `getLastBuildParameters()`.
### Coverage
| Case | Fixed here |
|---|---|
| `coder update`, old version purged, active version healthy | yes |
| Workspace sits on a purged version, autostop then autostart | no,
needs the discard loop fix |
| `require_active_version` where the active version is purged | no,
needs the discard loop fix |
### Changes
1. `resolver.go`: gate the discard loop on the build transition.
Ephemeral trimming, immutability, monotonicity, and default backfill are
unchanged.
2. `wsbuilder.go`: pass `b.trans`. Single non-test caller.
### Deliberate calls
- `delete` is treated like `stop`. Neither transition changes which
parameters a workspace has, and it keeps the condition to one
comparison.
- The transition is passed rather than a second boolean flag, so the
call site stays unambiguous next to `firstBuild`.
</details>
---
🤖 Authored by Coder Agents on behalf of @Emyrk.
Removes the coder_secret Terraform integration: the data.coder_secret
consumption path through provisionerdserver → provisioner.proto →
provisioner/terraform, the dynamic-parameter secret-requirement
validation, and the workspace-update / resolve-autostart surfaces that
depended on it. This is being done due to a product/feature direction
change (see PLAT-243). User-secret CRUD (DB, REST, CLI, UI, telemetry, audit)
and the agent-manifest secret-injection path are untouched.
The provisionerd API is bumped from v1.17 to v1.18 rather than rolled
back: v1.17 shipped in v2.33.x, so user_secrets field numbers are
reserved and the changelog documents both versions.
Generated with assistance from Coder Agents.
Adds `dynamicparameters.EvaluateSecretMismatch` as a shared helper on
top of the existing renderer, then wires it into the resolve-autostart
handler so the UI can surface unsatisfied `coder_secret` requirements in
a template alongside parameter mismatch for autostart.
The lifecycle executor changes will land in a follow-up that depend
on this helper. The UI changes that consume the new `secret_mismatch`
field is also a follow-up.
Generated with assistance from Coder Agents.
Adds structured `secret_requirements` to dynamic parameter responses and
enforces missing required secrets during workspace start.
Stop, delete, and tag rendering paths skip secret requirement
enforcement so unmet secrets do not prevent cleanup. The SDK, generated
API docs/types, and backend render/resolver/wsbuilder tests are updated
for the new contract.
Archiving modules attempts to save as many modules as it can before it hits the limit. Enabling the template as much as it can, rather than a hard failure.
When in experimental this was used as an escape hatch. Removed to be
consistent with the template author's intentions
Backwards compatible, removing an experimental api field that is no longer used.
# What does this do?
This does parameter validation for dynamic parameters in `wsbuilder`. All input parameters are validated in `coder/coder` before being sent to terraform.
The heart of this PR is [`ResolveParameters`](https://github.com/coder/coder/blob/b65001e89c0577199a8e470c138c51e91cf2350c/coderd/dynamicparameters/resolver.go#L30-L30).
# What else changes?
`wsbuilder` now needs to load the terraform files into memory to succeed. This does add a larger memory requirement to workspace builds.
# Future work
- Sort autostart handling workspaces by template version id. So workspaces with the same template version only load the terraform files once from the db, and store them in the cache.
This PR extracts dynamic parameter rendering logic from
coderd/parameters.go into a new coderd/dynamicparameters package. Partly
for organization and maintainability, but primarily to be reused in
`wsbuilder` to be leveraged as validation.
This removes the opt-in and opt-out buttons for dynamic parameters on
the create workspace page and the workspace parameters settings page.
---------
Co-authored-by: Steven Masley <stevenmasley@gmail.com>
The existing code persists all static parameters and their values. Using
the previous build as the source if no new inputs are found.
Dynamic params do not have a state of the parameters saved to disk. So
instead, all previous values are persisted always, and new inputs
override.
Existing template versions do not have the metadata (modules + plan) in
the db. So revert to using static parameter information from the
original template import.
This data will still be served over the websocket.
* chore: Move httpmw to /coderd directory
httpmw is specific to coderd and should be scoped under coderd
* chore: Move httpapi to /coderd directory
httpapi is specific to coderd and should be scoped under coderd
* chore: Move database to /coderd directory
database is specific to coderd and should be scoped under coderd
* chore: Update codecov & gitattributes for generated files
* chore: Update Makefile