Skip to content

Commit

Permalink
Fix a nil pointer dereference in firestore index creation
Browse files Browse the repository at this point in the history
#3766 removed a nil
pointer check when creating firestore indexes. This was a legitimate
check, for when indexes already exist.

Tested this manually. Unit testing is trickier because the firestore
emulator in gcloud doesn't support indexes.
  • Loading branch information
Andrew Lytvynov authored and awly committed Jul 15, 2020
1 parent 5c4039a commit d5c2d63
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/backend/firestore/firestorebk.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,14 @@ func EnsureIndexes(ctx context.Context, adminSvc *apiv1.FirestoreAdminClient, tu
return ConvertGRPCError(err)
}

meta := adminpb.IndexOperationMetadata{}
if err := proto.Unmarshal(operation.Metadata.Value, &meta); err != nil {
return trace.Wrap(err)
// operation can be nil if error code is codes.AlreadyExists.
if operation != nil {
meta := adminpb.IndexOperationMetadata{}
if err := proto.Unmarshal(operation.Metadata.Value, &meta); err != nil {
return trace.Wrap(err)
}
tuplesToIndexNames[tuple] = meta.Index
}
tuplesToIndexNames[tuple] = meta.Index
}

// Instead of polling the Index state, we should wait for the Operation to
Expand Down

0 comments on commit d5c2d63

Please sign in to comment.