Skip to content

Commit

Permalink
Don't crash when populating NewExtra.
Browse files Browse the repository at this point in the history
When populating NewExtra, we iterate over attributes and inspect their
NewExtra property. In the case of null attributes, this results in a
crash, as we're dereferencing a nil pointer.

I'm still not clear on why this is happening, where it's coming from, or
what it means. The current understanding is it has something to do with
usage of CustomizeDiff. I'm not sure why yet. But this commit at least
surfaces which attribute was null, by logging it, and prevents the
crash, even if it doesn't resolve the problem.
  • Loading branch information
paddycarver committed Jan 27, 2021
1 parent 77af0e5 commit 571b073
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helper/schema/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,10 @@ func (s *GRPCProviderServer) PlanResourceChange(ctx context.Context, req *tfprot
newExtra := map[string]interface{}{}

for k, v := range diff.Attributes {
if v == nil {
log.Printf("[WARN] Field %q was null, not modifying its NewExtra", k)
continue
}
if v.NewExtra != nil {
newExtra[k] = v.NewExtra
}
Expand Down

0 comments on commit 571b073

Please sign in to comment.