CtrlK
BlogDocsLog inGet started
Tessl Logo

framework-null-vs-unknown-in-extractors

In `extract*` helpers under `internal/provider/**/resource_*.go` that feed `Replace*`/`Update*` SDK calls, never collapse `IsNull()` and `IsUnknown()` into one branch. Null = clear; unknown = omit.

69

Quality

83%

Does it follow best practices?

Impact

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

SKILL.md
Quality
Evals
Security

Null vs Unknown in extractor helpers

Trigger: an extractor turns a types.Set/List/Map/Object into an SDK request body, and you see if x.IsNull() || x.IsUnknown() returning the same value.

Fix:

if x.IsUnknown() {
    return nil, nil               // omit key → server keeps existing value
}
if x.IsNull() {
    return []sdk.Foo{}, nil       // explicit empty → server clears on Replace
}

Why: the SDK's ToMap() uses IsNil() to decide whether to emit a JSON key. Collapsing both states either silently preserves removed values (both → nil) or silently destroys values still being resolved (both → empty slice).

Repository
coralogix/terraform-provider-coralogix
Last updated
Created

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.