Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20260903-103534.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ENHANCEMENTS
body: 'all: Improved performance of resource read, create and update and of data source
read by no longer deep-comparing the entire value to detect semantic equality changes'
time: 2026-09-03T10:35:34+03:30
custom:
Issue: "1322"
9 changes: 9 additions & 0 deletions internal/fwserver/schema_semantic_equality.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type SchemaSemanticEqualityResponse struct {
// NewData is the new schema-based data after any modifications.
NewData fwschemadata.Data

// Modified reports whether any value in NewData was replaced by its prior
// value. Callers use this instead of comparing NewData against the data
// they passed in, which is a deep comparison of the whole value.
Modified bool

// Diagnostics report errors or warnings related to running all attribute
// plan modifiers. Returning an empty slice indicates a successful
// plan modification with no warnings or errors generated.
Expand Down Expand Up @@ -91,6 +96,8 @@ func SchemaSemanticEquality(ctx context.Context, req SchemaSemanticEqualityReque
continue
}

resp.Modified = true

resp.Diagnostics.Append(resp.NewData.SetAtPath(ctx, valueReq.Path, valueResp.NewValue)...)

if resp.Diagnostics.HasError() {
Expand Down Expand Up @@ -137,6 +144,8 @@ func SchemaSemanticEquality(ctx context.Context, req SchemaSemanticEqualityReque
continue
}

resp.Modified = true

resp.Diagnostics.Append(resp.NewData.SetAtPath(ctx, valueReq.Path, valueResp.NewValue)...)

if resp.Diagnostics.HasError() {
Expand Down
4 changes: 4 additions & 0 deletions internal/fwserver/schema_semantic_equality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func TestSchemaSemanticEquality(t *testing.T) {
},
},
expected: &fwserver.SchemaSemanticEqualityResponse{
Modified: true,
NewData: fwschemadata.Data{
Description: fwschemadata.DataDescriptionPlan,
Schema: testschema.Schema{
Expand Down Expand Up @@ -619,6 +620,7 @@ func TestSchemaSemanticEquality(t *testing.T) {
},
},
expected: &fwserver.SchemaSemanticEqualityResponse{
Modified: true,
NewData: fwschemadata.Data{
Description: fwschemadata.DataDescriptionPlan,
Schema: testschema.Schema{
Expand Down Expand Up @@ -1325,6 +1327,7 @@ func TestSchemaSemanticEquality(t *testing.T) {
},
},
expected: &fwserver.SchemaSemanticEqualityResponse{
Modified: true,
NewData: fwschemadata.Data{
Description: fwschemadata.DataDescriptionPlan,
Schema: testschema.Schema{
Expand Down Expand Up @@ -1966,6 +1969,7 @@ func TestSchemaSemanticEquality(t *testing.T) {
},
},
expected: &fwserver.SchemaSemanticEqualityResponse{
Modified: true,
NewData: fwschemadata.Data{
Description: fwschemadata.DataDescriptionPlan,
Schema: testschema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion internal/fwserver/server_createresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (s *Server) CreateResource(ctx context.Context, req *CreateResourceRequest,
return
}

if !semanticEqualityResp.NewData.TerraformValue.Equal(resp.NewState.Raw) {
if semanticEqualityResp.Modified {
logging.FrameworkDebug(ctx, "State updated due to semantic equality")

resp.NewState.Raw = semanticEqualityResp.NewData.TerraformValue
Expand Down
2 changes: 1 addition & 1 deletion internal/fwserver/server_readdatasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (s *Server) ReadDataSource(ctx context.Context, req *ReadDataSourceRequest,
return
}

if semanticEqualityResp.NewData.TerraformValue.Equal(resp.State.Raw) {
if !semanticEqualityResp.Modified {
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/fwserver/server_readresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (s *Server) ReadResource(ctx context.Context, req *ReadResourceRequest, res
return
}

if !semanticEqualityResp.NewData.TerraformValue.Equal(resp.NewState.Raw) {
if semanticEqualityResp.Modified {
logging.FrameworkDebug(ctx, "State updated due to semantic equality")

resp.NewState.Raw = semanticEqualityResp.NewData.TerraformValue
Expand Down
2 changes: 1 addition & 1 deletion internal/fwserver/server_updateresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (s *Server) UpdateResource(ctx context.Context, req *UpdateResourceRequest,
return
}

if !semanticEqualityResp.NewData.TerraformValue.Equal(resp.NewState.Raw) {
if semanticEqualityResp.Modified {
logging.FrameworkDebug(ctx, "State updated due to semantic equality")

resp.NewState.Raw = semanticEqualityResp.NewData.TerraformValue
Expand Down