Skip to content

Commit

Permalink
Mirror stats: ensure we dont send nulls (#2169)
Browse files Browse the repository at this point in the history
Designing client side applications is tricky when you have to account
for fields being undefined/null. This PR ensures that our stats
endpoints return empty arrays at the very least
  • Loading branch information
Amogh-Bharadwaj authored Oct 22, 2024
1 parent 895c643 commit 12113b6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flow/cmd/mirror_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ func (h *FlowRequestHandler) GetCDCBatches(ctx context.Context, req *protos.GetC
return nil, err
}

if batches == nil {
batches = []*protos.CDCBatch{}
}

return &protos.GetCDCBatchesResponse{
CdcBatches: batches,
}, nil
Expand Down Expand Up @@ -545,6 +549,10 @@ func (h *FlowRequestHandler) CDCTableTotalCounts(
if err != nil {
return nil, err
}

if tableCounts == nil {
tableCounts = []*protos.CDCTableRowCounts{}
}
return &protos.CDCTableTotalCountsResponse{TotalData: &totalCount, TablesData: tableCounts}, nil
}

Expand Down

0 comments on commit 12113b6

Please sign in to comment.