Skip to content

Improve wording of for_each key dependency error when using a set#37824

Closed
LeoCie wants to merge 1 commit intohashicorp:mainfrom
LeoCie:improve-for-each-error-wording
Closed

Improve wording of for_each key dependency error when using a set#37824
LeoCie wants to merge 1 commit intohashicorp:mainfrom
LeoCie:improve-for-each-error-wording

Conversation

@LeoCie
Copy link

@LeoCie LeoCie commented Oct 28, 2025

The wording of this error is confusing, it mixes the "values" of a set, and the "values" of a map. I have reworded to make it clear what is being talked about - the "elements" of a set, and the "keys/values" of a map.

This change only affects the error messaging, and nothing else.

Target Release

1.15.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

None.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@LeoCie LeoCie requested a review from a team as a code owner October 28, 2025 10:58
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Oct 28, 2025

CLA assistant check
All committers have signed the CLA.

hcltest.MockExprLiteral(cty.UnknownVal(cty.Set(cty.String))),
"Invalid for_each argument",
"set includes values derived from resource attributes that cannot be determined until apply",
"set includes elements derived from resource attributes that cannot be determined until apply",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "elements" of a set are the conceptual placeholders for the value (in the implementation, Element() actually returns the key-value pair), but it is still a "value" which is derived from an expression. I see how the wording above is a bit clumsy with the repeated use of "value", but I don't think this is more clear. That could be because I'm used to communicating in Terraform's language, so I wonder if anyone else find this problematic enough to change.

@crw
Copy link
Contributor

crw commented Feb 9, 2026

Given the comment from @jbardin and no further follow-up, I'm going to close this one. Thanks for this submission, I think we would still be open to some manner of clarification of this language.

@crw crw closed this Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments