Skip to content

fix(cli): allow new immutable parameters via --parameter flag during update#22221

Merged
kacpersaw merged 2 commits intomainfrom
kacpersaw/fix-immutable-param-update
Feb 24, 2026
Merged

fix(cli): allow new immutable parameters via --parameter flag during update#22221
kacpersaw merged 2 commits intomainfrom
kacpersaw/fix-immutable-param-update

Conversation

@kacpersaw
Copy link
Contributor

Problem

When a template adds a new immutable parameter, coder update --parameter param=value fails with:

error: start workspace: parameter "machine_type" is immutable and cannot be updated

The interactive prompt handles this correctly (allows setting first-time immutable params), but the CLI --parameter flag path does not.

Root Cause

In cli/parameterresolver.go, verifyConstraints() runs before the interactive prompt and unconditionally rejects any immutable parameter during updates. It doesn't distinguish between new immutable parameters (first-time use, should be allowed) and existing ones (already set, should be blocked from changing).

Fix

Added an isFirstTimeUse check to the immutable parameter constraint, matching the logic already used by the interactive prompt path (line 323). New immutable parameters can now be set via --parameter, while existing immutable parameters are still blocked from being changed.

Testing

Added TestUpdateValidateRichParameters/NewImmutableParameterViaFlag which:

  1. Creates a workspace with a mutable parameter
  2. Updates the template to add a new immutable parameter
  3. Runs coder update --parameter immutable_param=value
  4. Verifies the update succeeds and the parameter is set correctly

Fixes #22164

@kacpersaw kacpersaw force-pushed the kacpersaw/fix-immutable-param-update branch from 3be8e22 to c9d25f2 Compare February 23, 2026 14:03
…update

When a template adds a new immutable parameter, `coder update --parameter`
would reject it with "parameter is immutable and cannot be updated". This
happened because verifyConstraints() didn't distinguish between new immutable
parameters (first-time use, should be allowed) and existing ones (should be
blocked from changing).

The fix adds an isFirstTimeUse check, matching the logic already used by
the interactive prompt path.

Fixes #22164
@kacpersaw kacpersaw force-pushed the kacpersaw/fix-immutable-param-update branch from c9d25f2 to 3910f37 Compare February 23, 2026 14:07
@kacpersaw kacpersaw marked this pull request as ready for review February 23, 2026 14:14
@kacpersaw kacpersaw merged commit 3c69d68 into main Feb 24, 2026
46 of 49 checks passed
@kacpersaw kacpersaw deleted the kacpersaw/fix-immutable-param-update branch February 24, 2026 08:15
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: coder update: impossible to specify new immutable parameter non-interactively

2 participants