Fix missing AttributePathExpression in plan modifier requests for top level attributes and blocks#1260
Open
ChihweiLHBird wants to merge 7 commits intohashicorp:mainfrom
Conversation
…-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>
There was a problem hiding this comment.
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)toModifyAttributePlanRequestfor both top-level attributes and blocks - Added a comprehensive test case verifying that
PathExpressionis 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Fixes #1258
Description
This PR fixes a bug where
AttributePathExpressionwas missing in plan modifier requests for top-level attributes and blocks. The issue occurred in theSchemaModifyPlanfunction whereModifyAttributePlanRequeststructs were created without populating theAttributePathExpressionfield.Problem
When plan modifiers were called for top-level attributes and blocks, the
PathExpressionfield in the request was empty, which could cause issues for plan modifiers that rely on this information for path-based operations.Solution
AttributePathExpression: path.MatchRoot(name)to both attribute and block request creation inSchemaModifyPlan"attribute-pathexpression"to verify thePathExpressionis correctly populatedOptional: true, Computed: trueto better simulate real-world plan modifier usageChanges
internal/fwserver/schema_plan_modification.go: Added missingAttributePathExpressionfield initializationinternal/fwserver/schema_plan_modification_test.go: Added new test case and updated attribute configurationTesting
go test ./internal/fwserver/... -vPathExpressionis correctly set topath.MatchRoot("test")for top-level attributes