Skip to content

Fix missing AttributePathExpression in plan modifier requests for top level attributes and blocks#1260

Open
ChihweiLHBird wants to merge 7 commits intohashicorp:mainfrom
ChihweiLHBird:zhiwei/fix-schema-plan-modification-path-expression
Open

Fix missing AttributePathExpression in plan modifier requests for top level attributes and blocks#1260
ChihweiLHBird wants to merge 7 commits intohashicorp:mainfrom
ChihweiLHBird:zhiwei/fix-schema-plan-modification-path-expression

Conversation

@ChihweiLHBird
Copy link
Copy Markdown
Contributor

@ChihweiLHBird ChihweiLHBird commented Jan 23, 2026

Related Issue

Fixes #1258

Description

This PR fixes a bug where AttributePathExpression was missing in plan modifier requests for top-level attributes and blocks. The issue occurred in the SchemaModifyPlan function where ModifyAttributePlanRequest structs were created without populating the AttributePathExpression field.

Problem

When plan modifiers were called for top-level attributes and blocks, the PathExpression field in the request was empty, which could cause issues for plan modifiers that rely on this information for path-based operations.

Solution

  • Added AttributePathExpression: path.MatchRoot(name) to both attribute and block request creation in SchemaModifyPlan
  • Added a comprehensive test case "attribute-pathexpression" to verify the PathExpression is correctly populated
  • Updated the test attribute to be Optional: true, Computed: true to better simulate real-world plan modifier usage

Changes

  1. internal/fwserver/schema_plan_modification.go: Added missing AttributePathExpression field initialization
  2. internal/fwserver/schema_plan_modification_test.go: Added new test case and updated attribute configuration

Testing

go test ./internal/fwserver/... -v
  • All existing tests continue to pass
  • New test verifies PathExpression is correctly set to path.MatchRoot("test") for top-level attributes
  • Test uses optional/computed attribute to simulate typical plan modifier scenarios

…-level attributes and blocks, and add test

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
…plan modifier running

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird ChihweiLHBird marked this pull request as ready for review January 23, 2026 17:24
@ChihweiLHBird ChihweiLHBird requested a review from a team as a code owner January 23, 2026 17:24
Copilot AI review requested due to automatic review settings January 23, 2026 17:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the AttributePathExpression field was missing from plan modifier requests for top-level attributes and blocks in the SchemaModifyPlan function. The missing field caused issues for plan modifiers that rely on PathExpression for operations like path.MatchRelative(), as reported in issue #1258.

Changes:

  • Added AttributePathExpression: path.MatchRoot(name) to ModifyAttributePlanRequest for both top-level attributes and blocks
  • Added a comprehensive test case verifying that PathExpression is correctly populated for top-level attributes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/fwserver/schema_plan_modification.go Added AttributePathExpression field initialization for top-level attributes (line 87) and blocks (line 145)
internal/fwserver/schema_plan_modification_test.go Added new test case "attribute-pathexpression" to verify PathExpression is correctly set to path.MatchRoot("test") for top-level attributes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/fwserver/schema_plan_modification.go
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.

Empty PathExpression in Plan Modifiers breaks path.MatchRelative()

2 participants