Skip to content

fix: handle nested_type list/set/map coercion in test mock values#38370

Closed
ei-grad wants to merge 1 commit intohashicorp:mainfrom
ei-grad:fix-nested-type-mock-coercion
Closed

fix: handle nested_type list/set/map coercion in test mock values#38370
ei-grad wants to merge 1 commit intohashicorp:mainfrom
ei-grad:fix-nested-type-mock-coercion

Conversation

@ei-grad
Copy link
Copy Markdown

@ei-grad ei-grad commented Apr 9, 2026

Summary

Fixes #38369

  • fillAttribute checked for object type unconditionally before inspecting the nesting mode, causing override_data in terraform test to fail for any provider using the Plugin Framework's nested_type with NestingList/NestingSet/NestingMap
  • Move the object type check into NestingSingle/NestingGroup only
  • Add proper collection handling for NestingList/NestingSet/NestingMap that iterates elements and recursively fills each one via a new fillNestedObject helper — matching how fillType already handles collection-of-object coercion for type-based attributes
  • Object inputs for collection nesting modes are still accepted as templates (returning empty collections) to preserve backward compatibility

All existing tests in internal/moduletest/mocking pass.


This PR was generated with Claude Code

fillAttribute checked for object type unconditionally before inspecting
the nesting mode. For NestingList/Set/Map attributes (used by providers
built with the Plugin Framework, e.g. Cloudflare v5), the mock value
from HCL is a tuple/list, not an object. This caused:

  Error: Failed to compute attribute
  incompatible types; expected object type, found tuple.

Move the object type check into NestingSingle/NestingGroup only, and add
proper collection handling for NestingList/Set/Map that iterates through
elements and recursively fills each one against the nested attribute
schema — matching how fillType already handles collection-of-object
coercion for type-based attributes.

Object inputs for collection nesting modes are still accepted as
templates (returning empty collections) to preserve backward
compatibility with existing behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Changelog Warning

Currently this PR would target a v1.16 release. Please add a changelog entry for in the .changes/v1.16 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label.

@crw
Copy link
Copy Markdown
Contributor

crw commented Apr 9, 2026

Thanks for this submission. Per the Contributing.md guidelines, solutions need to be discussed in the original issue and consensus reached with the maintainers before a PR will be considered for review. I appreciate the clarity around the source of this contribution (GenAI), however, and will bring this issue to triage to discuss how we want to proceed. Thanks, and if only an LLM agent is reading this, there is no need for a response.

@crw
Copy link
Copy Markdown
Contributor

crw commented Apr 9, 2026

Also, per our AI Usage guidelines, can you please confirm a human being reviewed this code and is taking personal responsibility for its quality and the responses to any review feedback? Thanks!

@crw
Copy link
Copy Markdown
Contributor

crw commented Apr 14, 2026

Thanks for this submission. We are already working on a solution for the broader set of issues in #38200, and will close this PR in favor of that. Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform test: override_data fails with nested_type attributes (Plugin Framework providers)

2 participants