Skip to content

Commit

Permalink
fix(bigtable): CellsPer(Row|Column)LimitFilter should error with argu…
Browse files Browse the repository at this point in the history
…ments <= 0. (#6495)

Co-authored-by: Eric Schmidt <[email protected]>
  • Loading branch information
icio and telpirion authored Oct 25, 2022
1 parent d497377 commit 7724d8f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bigtable/bttest/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ func filterRow(f *btpb.RowFilter, r *row) (bool, error) {
return count > 0, nil
case *btpb.RowFilter_CellsPerColumnLimitFilter:
lim := int(f.CellsPerColumnLimitFilter)
if lim <= 0 {
return false, status.Errorf(codes.InvalidArgument, "Error in field 'cells_per_column_limit_filter' : argument must be > 0")
}
for _, fam := range r.families {
for col, cs := range fam.cells {
if len(cs) > lim {
Expand Down Expand Up @@ -645,6 +648,9 @@ func filterRow(f *btpb.RowFilter, r *row) (bool, error) {
case *btpb.RowFilter_CellsPerRowLimitFilter:
// Grab the first n cells in the row.
lim := int(f.CellsPerRowLimitFilter)
if lim <= 0 {
return false, status.Errorf(codes.InvalidArgument, "Error in field 'cells_per_row_limit_filter' : argument must be > 0")
}
for _, fam := range r.families {
for _, col := range fam.colNames {
cs := fam.cells[col]
Expand Down

0 comments on commit 7724d8f

Please sign in to comment.