Unknown parameter default coerced to null skips the 'value is unknown' diagnostic
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go
- Domain
- backend, testing-qa
Research direction
Start in extract/parameter.go at ParameterUsageDiagnostics and reproduce the case from testdata/resourceclosure2, comparing a computed attribute with a missing reference. Review the computed vector mentioned in #224, then verify that an unknown default consistently receives the intended unknown/unresolved diagnostic and that the regression behavior is covered.
Written by the indexing model from the issue text.
Description
Summary
A parameter whose default is an unknown value can surface either as an error diagnostic or as a silent null, depending on how the unknown arrives. Both cases are "the value could not be resolved", but only one of them tells the user.
Repro
testdata/resourceclosure2 on main (from #224):
resource "docker_image" "base" { name = "large" }
data "coder_parameter" "computed" {
name = "computed"
type = "string"
default = docker_image.base.image_id # computed attribute, unknown at plan time
}
Result on main:
value=cty.NullVal(cty.String) valid=false known=false null=true default=cty.DynamicVal diags=0
DefaultValue is cty.DynamicVal, Value ends up as a typed null, and the parameter carries no diagnostics.
Compare a default that is unknown because a reference has no value (for example default = local.x where local.x reads a block that does not exist). There the value stays an unknown and ParameterUsageDiagnostics emits:
Parameter value is unknown, it likely includes a reference without a value
Where it diverges
extract/parameter.go, ParameterUsageDiagnostics:
if p.Value.Value.IsNull() {
// Allow null values
} else if !p.Value.Valid() {
...
} else if !p.Value.IsKnown() {
... "Parameter value is unknown" ...
}
The null branch is checked first, so an unknown default that is coerced to a typed null on the way to Value skips both the "not valid" and "unknown" branches, even though Valid() and IsKnown() are both false on it.
Expected
Either both shapes report the same "unknown / unresolved" diagnostic, or neither does. A user writing default = <computed attribute> gets a required-but-empty parameter in the form with no explanation today.
Notes
- Found while writing #224; the
computedvector there pins the current behavior withap().unknown()and no diagnostic assertion, so it will not block a fix. - Not related to the resource-closure work in #221; reproduces on
mainwith no pruning.
Filed by Emyrk with Coder Agents assistance.
- Dominant language
- Go
- Stars
- 9
- Forks
- 5
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from coder/preview
-
bug
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
upstream
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100