diff --git a/pkg/tfbridge/provider.go b/pkg/tfbridge/provider.go index 50593a885a..fd7319f707 100644 --- a/pkg/tfbridge/provider.go +++ b/pkg/tfbridge/provider.go @@ -19,6 +19,7 @@ import ( "fmt" "log" "os" + "q" "sort" "strings" "time" @@ -1340,6 +1341,7 @@ func (p *Provider) Create(ctx context.Context, req *pulumirpc.CreateRequest) (*p var reasons []string if !req.GetPreview() { newstate, err = p.tf.Apply(ctx, res.TFName, nil, diff) + q.Q(newstate, err) if newstate == nil { if err == nil { return nil, fmt.Errorf("expected non-nil error with nil state during Create of %s", urn) diff --git a/pkg/tfshim/sdk-v2/provider2.go b/pkg/tfshim/sdk-v2/provider2.go index ef6e33438c..6344e2859b 100644 --- a/pkg/tfshim/sdk-v2/provider2.go +++ b/pkg/tfshim/sdk-v2/provider2.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "maps" + "q" "sort" "strings" "time" @@ -348,8 +349,9 @@ func (p *planResourceChangeImpl) Apply( } resp, err := p.server.ApplyResourceChange(ctx, t, ty, cfg, st, pl, priv, meta) + q.Q(resp, err) if err != nil { - return nil, err + return resp, err } return &v2InstanceState2{ resourceType: t, @@ -662,25 +664,26 @@ func (s *grpcServer) ApplyResourceChange( } req.ProviderMeta = &tfprotov5.DynamicValue{MsgPack: providerMetaVal} } - resp, err := s.gserver.ApplyResourceChange(ctx, req) - if err := handleDiagnostics(ctx, resp.Diagnostics, err); err != nil { - return nil, err - } - newState, err := msgpack.Unmarshal(resp.NewState.MsgPack, ty) - if err != nil { - return nil, err - } + resp, applyErr := s.gserver.ApplyResourceChange(ctx, req) + newState := cty.Value{} var meta map[string]interface{} - if resp.Private != nil { - if err := json.Unmarshal(resp.Private, &meta); err != nil { + if resp != nil && resp.NewState != nil { + newState, err = msgpack.Unmarshal(resp.NewState.MsgPack, ty) + if err != nil { return nil, err } + if resp.Private != nil { + if err := json.Unmarshal(resp.Private, &meta); err != nil { + return nil, err + } + } } + returnErr := handleDiagnostics(ctx, resp.Diagnostics, applyErr) return &v2InstanceState2{ resourceType: typeName, stateValue: newState, meta: meta, - }, nil + }, returnErr } func (s *grpcServer) ReadResource(