Skip to content

Commit 3557b60

Browse files
authored
all: Modify CallFunction implementations (#226) (#226)
Reference: hashicorp/terraform-plugin-go#380 The next versions of the plugin protocol (5.5/6.5) include support for the CallFunction RPC and server capability. This change includes a modified implementation of the new RPC in all server implementations which accounts for returning a FunctionError rather than Diagnostics.
1 parent 963d34b commit 3557b60

File tree

13 files changed

+175
-117
lines changed

13 files changed

+175
-117
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: ENHANCEMENTS
2+
body: 'all: Upgrade protocol versions to support modified `CallFunction` RPC which
3+
returns a FunctionError rather than Diagnostics'
4+
time: 2024-02-23T09:47:29.580412Z
5+
custom:
6+
Issue: "226"

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/hashicorp/terraform-plugin-mux
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
github.com/google/go-cmp v0.6.0
7-
github.com/hashicorp/terraform-plugin-go v0.21.0
7+
github.com/hashicorp/terraform-plugin-go v0.22.0
88
github.com/hashicorp/terraform-plugin-log v0.9.0
9-
google.golang.org/grpc v1.61.0
9+
google.golang.org/grpc v1.62.0
1010
)
1111

1212
require (
@@ -24,9 +24,9 @@ require (
2424
github.com/oklog/run v1.0.0 // indirect
2525
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
2626
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
27-
golang.org/x/net v0.18.0 // indirect
28-
golang.org/x/sys v0.14.0 // indirect
27+
golang.org/x/net v0.20.0 // indirect
28+
golang.org/x/sys v0.16.0 // indirect
2929
golang.org/x/text v0.14.0 // indirect
30-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
30+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
3131
google.golang.org/protobuf v1.32.0 // indirect
3232
)

go.sum

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
2+
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
23
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
34
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
45
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -16,8 +17,8 @@ github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDm
1617
github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
1718
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
1819
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
19-
github.com/hashicorp/terraform-plugin-go v0.21.0 h1:VSjdVQYNDKR0l2pi3vsFK1PdMQrw6vGOshJXMNFeVc0=
20-
github.com/hashicorp/terraform-plugin-go v0.21.0/go.mod h1:piJp8UmO1uupCvC9/H74l2C6IyKG0rW4FDedIpwW5RQ=
20+
github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc=
21+
github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE=
2122
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
2223
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
2324
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
@@ -27,6 +28,7 @@ github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv2
2728
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
2829
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
2930
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
31+
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
3032
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
3133
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
3234
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -46,22 +48,22 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
4648
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
4749
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
4850
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
49-
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
50-
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
51+
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
52+
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
5153
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5254
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
5355
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5456
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5557
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
56-
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
57-
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
58+
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
59+
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
5860
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
5961
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
6062
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
61-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14=
62-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA=
63-
google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
64-
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
63+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
64+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
65+
google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
66+
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
6567
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
6668
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
6769
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=

internal/tfprotov5tov6/tfprotov5tov6.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func CallFunctionResponse(in *tfprotov5.CallFunctionResponse) *tfprotov6.CallFun
5959
}
6060

6161
return &tfprotov6.CallFunctionResponse{
62-
Diagnostics: Diagnostics(in.Diagnostics),
63-
Result: DynamicValue(in.Result),
62+
Error: FunctionError(in.Error),
63+
Result: DynamicValue(in.Result),
6464
}
6565
}
6666

@@ -148,6 +148,19 @@ func Function(in *tfprotov5.Function) *tfprotov6.Function {
148148
return out
149149
}
150150

151+
func FunctionError(in *tfprotov5.FunctionError) *tfprotov6.FunctionError {
152+
if in == nil {
153+
return nil
154+
}
155+
156+
out := &tfprotov6.FunctionError{
157+
Text: in.Text,
158+
FunctionArgument: in.FunctionArgument,
159+
}
160+
161+
return out
162+
}
163+
151164
func FunctionMetadata(in tfprotov5.FunctionMetadata) tfprotov6.FunctionMetadata {
152165
return tfprotov6.FunctionMetadata{
153166
Name: in.Name,

internal/tfprotov5tov6/tfprotov5tov6_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
1111
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
1212
"github.com/hashicorp/terraform-plugin-go/tftypes"
13+
1314
"github.com/hashicorp/terraform-plugin-mux/internal/tfprotov5tov6"
1415
)
1516

@@ -49,6 +50,16 @@ var (
4950
},
5051
}
5152

53+
testTfprotov5FunctionError *tfprotov5.FunctionError = &tfprotov5.FunctionError{
54+
Text: "test error",
55+
FunctionArgument: pointer(int64(0)),
56+
}
57+
58+
testTfprotov6FunctionError *tfprotov6.FunctionError = &tfprotov6.FunctionError{
59+
Text: "test error",
60+
FunctionArgument: pointer(int64(0)),
61+
}
62+
5263
testTfprotov5FunctionMetadata tfprotov5.FunctionMetadata = tfprotov5.FunctionMetadata{
5364
Name: "test_function",
5465
}
@@ -246,12 +257,12 @@ func TestCallFunctionResponse(t *testing.T) {
246257
},
247258
"all-valid-fields": {
248259
in: &tfprotov5.CallFunctionResponse{
249-
Diagnostics: testTfprotov5Diagnostics,
250-
Result: &testTfprotov5DynamicValue,
260+
Error: testTfprotov5FunctionError,
261+
Result: &testTfprotov5DynamicValue,
251262
},
252263
expected: &tfprotov6.CallFunctionResponse{
253-
Diagnostics: testTfprotov6Diagnostics,
254-
Result: &testTfprotov6DynamicValue,
264+
Error: testTfprotov6FunctionError,
265+
Result: &testTfprotov6DynamicValue,
255266
},
256267
},
257268
}
@@ -2037,3 +2048,7 @@ func TestValidateResourceConfigResponse(t *testing.T) {
20372048
})
20382049
}
20392050
}
2051+
2052+
func pointer[T any](value T) *T {
2053+
return &value
2054+
}

internal/tfprotov6tov5/tfprotov6tov5.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func CallFunctionResponse(in *tfprotov6.CallFunctionResponse) *tfprotov5.CallFun
6464
}
6565

6666
return &tfprotov5.CallFunctionResponse{
67-
Diagnostics: Diagnostics(in.Diagnostics),
68-
Result: DynamicValue(in.Result),
67+
Error: FunctionError(in.Error),
68+
Result: DynamicValue(in.Result),
6969
}
7070
}
7171

@@ -153,6 +153,19 @@ func Function(in *tfprotov6.Function) *tfprotov5.Function {
153153
return out
154154
}
155155

156+
func FunctionError(in *tfprotov6.FunctionError) *tfprotov5.FunctionError {
157+
if in == nil {
158+
return nil
159+
}
160+
161+
out := &tfprotov5.FunctionError{
162+
Text: in.Text,
163+
FunctionArgument: in.FunctionArgument,
164+
}
165+
166+
return out
167+
}
168+
156169
func FunctionMetadata(in tfprotov6.FunctionMetadata) tfprotov5.FunctionMetadata {
157170
return tfprotov5.FunctionMetadata{
158171
Name: in.Name,

internal/tfprotov6tov5/tfprotov6tov5_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
1313
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
1414
"github.com/hashicorp/terraform-plugin-go/tftypes"
15+
1516
"github.com/hashicorp/terraform-plugin-mux/internal/tfprotov6tov5"
1617
)
1718

@@ -62,6 +63,16 @@ var (
6263
},
6364
}
6465

66+
testTfprotov5FunctionError *tfprotov5.FunctionError = &tfprotov5.FunctionError{
67+
Text: "test error",
68+
FunctionArgument: pointer(int64(0)),
69+
}
70+
71+
testTfprotov6FunctionError *tfprotov6.FunctionError = &tfprotov6.FunctionError{
72+
Text: "test error",
73+
FunctionArgument: pointer(int64(0)),
74+
}
75+
6576
testTfprotov6FunctionMetadata tfprotov6.FunctionMetadata = tfprotov6.FunctionMetadata{
6677
Name: "test_function",
6778
}
@@ -248,12 +259,12 @@ func TestCallFunctionResponse(t *testing.T) {
248259
},
249260
"all-valid-fields": {
250261
in: &tfprotov6.CallFunctionResponse{
251-
Diagnostics: testTfprotov6Diagnostics,
252-
Result: &testTfprotov6DynamicValue,
262+
Error: testTfprotov6FunctionError,
263+
Result: &testTfprotov6DynamicValue,
253264
},
254265
expected: &tfprotov5.CallFunctionResponse{
255-
Diagnostics: testTfprotov5Diagnostics,
256-
Result: &testTfprotov5DynamicValue,
266+
Error: testTfprotov5FunctionError,
267+
Result: &testTfprotov5DynamicValue,
257268
},
258269
},
259270
}
@@ -2286,3 +2297,7 @@ func TestValidateResourceTypeConfigResponse(t *testing.T) {
22862297
})
22872298
}
22882299
}
2300+
2301+
func pointer[T any](value T) *T {
2302+
return &value
2303+
}

tf5muxserver/mux_server_CallFunction.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ package tf5muxserver
55

66
import (
77
"context"
8+
"fmt"
89

910
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
11+
1012
"github.com/hashicorp/terraform-plugin-mux/internal/logging"
1113
)
1214

@@ -24,8 +26,22 @@ func (s *muxServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctio
2426
}
2527

2628
if diagnosticsHasError(diags) {
29+
var text string
30+
31+
for _, d := range diags {
32+
if d.Severity == tfprotov5.DiagnosticSeverityError {
33+
if text != "" {
34+
text += "\n"
35+
}
36+
37+
text += fmt.Sprintf("%s: %s", d.Summary, d.Detail)
38+
}
39+
}
40+
2741
return &tfprotov5.CallFunctionResponse{
28-
Diagnostics: diags,
42+
Error: &tfprotov5.FunctionError{
43+
Text: text,
44+
},
2945
}, nil
3046
}
3147

@@ -37,13 +53,9 @@ func (s *muxServer) CallFunction(ctx context.Context, req *tfprotov5.CallFunctio
3753

3854
if !ok {
3955
resp := &tfprotov5.CallFunctionResponse{
40-
Diagnostics: []*tfprotov5.Diagnostic{
41-
{
42-
Severity: tfprotov5.DiagnosticSeverityError,
43-
Summary: "Provider Functions Not Implemented",
44-
Detail: "A provider-defined function call was received by the provider, however the provider does not implement functions. " +
45-
"Either upgrade the provider to a version that implements provider-defined functions or this is a bug in Terraform that should be reported to the Terraform maintainers.",
46-
},
56+
Error: &tfprotov5.FunctionError{
57+
Text: "Provider Functions Not Implemented: A provider-defined function call was received by the provider, however the provider does not implement functions. " +
58+
"Either upgrade the provider to a version that implements provider-defined functions or this is a bug in Terraform that should be reported to the Terraform maintainers.",
4759
},
4860
}
4961

tf5muxserver/mux_server_test.go

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,11 @@ func TestMuxServerGetFunctionServer_GetProviderSchema_Duplicate(t *testing.T) {
492492
// Terraform to verify the mutex does not deadlock.
493493
var wg sync.WaitGroup
494494

495-
expectedDiags := []*tfprotov5.Diagnostic{
496-
{
497-
Severity: tfprotov5.DiagnosticSeverityError,
498-
Summary: "Invalid Provider Server Combination",
499-
Detail: "The combined provider has multiple implementations of the same function name across underlying providers. " +
500-
"Functions must be implemented by only one underlying provider. " +
501-
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
502-
"Duplicate function: test_function",
503-
},
495+
expectedError := &tfprotov5.FunctionError{
496+
Text: "Invalid Provider Server Combination: The combined provider has multiple implementations of the same function name across underlying providers. " +
497+
"Functions must be implemented by only one underlying provider. " +
498+
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
499+
"Duplicate function: test_function",
504500
}
505501

506502
terraformOp := func() {
@@ -518,8 +514,8 @@ func TestMuxServerGetFunctionServer_GetProviderSchema_Duplicate(t *testing.T) {
518514
Name: "test_function",
519515
})
520516

521-
if diff := cmp.Diff(resp.Diagnostics, expectedDiags); diff != "" {
522-
t.Errorf("unexpected diagnostics difference: %s", diff)
517+
if diff := cmp.Diff(resp.Error, expectedError); diff != "" {
518+
t.Errorf("unexpected error difference: %s", diff)
523519
}
524520
}
525521

@@ -639,15 +635,11 @@ func TestMuxServerGetFunctionServer_GetMetadata_Duplicate(t *testing.T) {
639635
// Terraform to verify the mutex does not deadlock.
640636
var wg sync.WaitGroup
641637

642-
expectedDiags := []*tfprotov5.Diagnostic{
643-
{
644-
Severity: tfprotov5.DiagnosticSeverityError,
645-
Summary: "Invalid Provider Server Combination",
646-
Detail: "The combined provider has multiple implementations of the same function name across underlying providers. " +
647-
"Functions must be implemented by only one underlying provider. " +
648-
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
649-
"Duplicate function: test_function",
650-
},
638+
expectedError := &tfprotov5.FunctionError{
639+
Text: "Invalid Provider Server Combination: The combined provider has multiple implementations of the same function name across underlying providers. " +
640+
"Functions must be implemented by only one underlying provider. " +
641+
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
642+
"Duplicate function: test_function",
651643
}
652644

653645
terraformOp := func() {
@@ -665,7 +657,7 @@ func TestMuxServerGetFunctionServer_GetMetadata_Duplicate(t *testing.T) {
665657
Name: "test_function",
666658
})
667659

668-
if diff := cmp.Diff(resp.Diagnostics, expectedDiags); diff != "" {
660+
if diff := cmp.Diff(resp.Error, expectedError); diff != "" {
669661
t.Errorf("unexpected diagnostics difference: %s", diff)
670662
}
671663
}
@@ -784,14 +776,10 @@ func TestMuxServerGetFunctionServer_Missing(t *testing.T) {
784776
// Terraform to verify the mutex does not deadlock.
785777
var wg sync.WaitGroup
786778

787-
expectedDiags := []*tfprotov5.Diagnostic{
788-
{
789-
Severity: tfprotov5.DiagnosticSeverityError,
790-
Summary: "Function Not Implemented",
791-
Detail: "The combined provider does not implement the requested function. " +
792-
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
793-
"Missing function: test_function_nonexistent",
794-
},
779+
expectedError := &tfprotov5.FunctionError{
780+
Text: "Function Not Implemented: The combined provider does not implement the requested function. " +
781+
"This is always an issue in the provider implementation and should be reported to the provider developers.\n\n" +
782+
"Missing function: test_function_nonexistent",
795783
}
796784

797785
terraformOp := func() {
@@ -809,7 +797,7 @@ func TestMuxServerGetFunctionServer_Missing(t *testing.T) {
809797
Name: "test_function_nonexistent",
810798
})
811799

812-
if diff := cmp.Diff(resp.Diagnostics, expectedDiags); diff != "" {
800+
if diff := cmp.Diff(resp.Error, expectedError); diff != "" {
813801
t.Errorf("unexpected diagnostics difference: %s", diff)
814802
}
815803
}

0 commit comments

Comments
 (0)