CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

generated-state-upgrade-empty-collections

Use when a generated resource upgrades old state by refresh and the first plan shows labels or lists changing from [] or {} to null. Covers readEmptyAs and a flatten hook.

Quality

84%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

SKILL.md
Quality
Evals
Security

A refresh upgrade has no prior value, so empty collections read as []

Trigger: the upgraded state holds [] or {} where the plan (configuration without the attribute) holds null, and the first plan after the upgrade is not empty. A read with a prior value does not show it, because keepPriorEmpty keeps the null of the prior state.

Fix: state the null on the field: readEmptyAs: "null" for a list, a set, or a list of objects. A plain string map has no such key, so set it null in AfterFlatten when the attribute rejects an empty value (sizeAtLeast: 1), so the empty map cannot be configured. Test it: upgrade a raw state of every prior version through the protocol harness (UpgradeFrom), compare it with a read of the same alert, and plan the configuration on it (internal/provider/alert_state_upgrade_test.go).

Why: the upgrade passes no prior state to the flatten step, and the API answers an empty collection for a field that the user never set.

Repository

coralogix/terraform-provider-coralogix

Path

.claude/skills/generated-state-upgrade-empty-collections/SKILL.md

Last updated
First committed

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.