fix(cli): allow new immutable parameters via --parameter flag during update#22221
Merged
fix(cli): allow new immutable parameters via --parameter flag during update#22221
Conversation
3be8e22 to
c9d25f2
Compare
…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
c9d25f2 to
3910f37
Compare
deansheather
approved these changes
Feb 24, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
When a template adds a new immutable parameter,
coder update --parameter param=valuefails with:The interactive prompt handles this correctly (allows setting first-time immutable params), but the CLI
--parameterflag 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
isFirstTimeUsecheck 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/NewImmutableParameterViaFlagwhich:coder update --parameter immutable_param=valueFixes #22164