Skip to content

fwserver: set AttributePathExpression when modifying schema plans#1311

Open
emmayusufu wants to merge 1 commit into
hashicorp:mainfrom
emmayusufu:fix/schema-plan-modification-path-expression
Open

fwserver: set AttributePathExpression when modifying schema plans#1311
emmayusufu wants to merge 1 commit into
hashicorp:mainfrom
emmayusufu:fix/schema-plan-modification-path-expression

Conversation

@emmayusufu

Copy link
Copy Markdown

Related Issue

Fixes #1219

Description

SchemaModifyPlan built the top-level ModifyAttributePlanRequest with AttributePath set but AttributePathExpression left as the zero value. Every nested level then derived its expression from that empty root with AtName(...), so plan modifiers received expressions missing the root step. With the schema from the issue, the modifier on nested.double_nested.str_a saw double_nested.str_a, and a modifier on a first-level nested attribute saw a single bare step.

The fix sets AttributePathExpression: path.MatchRoot(name) in both the attributes and blocks loops, which is exactly how SchemaValidate already constructs its requests. The blocks loop had the same omission, and since both child-request sites in block_plan_modification.go and attribute_plan_modification.go derive from the parent expression, fixing the root repairs expressions at every nesting depth for attributes and blocks alike.

The new test runs the issue's two-level SingleNestedAttribute shape through SchemaModifyPlan and asserts the leaf modifier's req.PathExpression. Without the fix it fails with the exact output from the report (got: double_nested.str_a). The test covers the attribute path from the report; the block loop is the same one-line fix by symmetry, and I can add a block-shaped test if you would like one.

One behavior note: providers that observed the truncated expression and matched against it will now see the corrected full expression.

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

No changes to security controls.

SchemaModifyPlan built the top-level ModifyAttributePlanRequest without AttributePathExpression, so every nested request built on an empty expression and plan modifiers received paths missing the root step (a modifier on nested.double_nested.str_a saw double_nested.str_a). Set it from path.MatchRoot for attributes and blocks, matching SchemaValidate.
@emmayusufu
emmayusufu requested a review from a team as a code owner July 6, 2026 13:46
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.

Incorrect PathExpression Passed into Plan Modifier of an Attribute in a 2nd Layer Nested Object

1 participant