feat(attribute-values): Add counts to response and orderby#7960
Conversation
wmak
commented
May 22, 2026
- This adds counts to the AttributeValues endpoint so its a part of the response and the default sort so we're getting the most common values
- Also updates the protos to support this
- This adds counts to the AttributeValues endpoint so its a part of the response and the default sort so we're getting the most common values - Also updates the protos to support this
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bf90686. Configure here.
| ) | ||
| return TraceItemAttributeValuesResponse( | ||
| values=values, | ||
| counts=counts, |
There was a problem hiding this comment.
Cursor-based page token incompatible with new sort order
Medium Severity
The response page_token constructs a filter_offset cursor using attr_value > values[-1], which assumes results are sorted alphabetically by attr_value. The PR changed the primary sort to count() DESC, attr_value ASC, so values[-1] is no longer the alphabetically greatest value — it's just the last item in count-descending order. This makes the cursor semantically incorrect: it would skip values that belong on the next page or include values that don't. The offset-based path also doesn't account for the non-deterministic nature of count-based ordering across requests.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit bf90686. Configure here.
| name="attr_value", | ||
| expression=f.distinct(column(attr_value.alias, alias="attr_value")), | ||
| ), | ||
| SelectedExpression( |
There was a problem hiding this comment.
Redundant distinct wrapper with GROUP BY clause
Low Severity
f.distinct() wrapping attr_value is now redundant because the new groupby=[column("attr_value")] already guarantees unique values. In ClickHouse, this generates SELECT DISTINCT ... GROUP BY ... where the DISTINCT is a no-op. Keeping both deduplication mechanisms is confusing and obscures the query's actual semantics — GROUP BY is the operative deduplication here (needed for count()).
Reviewed by Cursor Bugbot for commit bf90686. Configure here.
phacops
left a comment
There was a problem hiding this comment.
The 2 cursor comments should be fixed before merging.

