From 5eba37bde53408fb75bd93e0d3ff1e76b4ef49ef Mon Sep 17 00:00:00 2001 From: Kyle Mumma Date: Thu, 2 Jan 2025 13:19:03 -0800 Subject: [PATCH] im a cat im a cat im a cat im a cat --- .../v1/endpoint_trace_item_attribute_names.py | 2 +- ...est_endpoint_trace_item_attribute_names.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/snuba/web/rpc/v1/endpoint_trace_item_attribute_names.py b/snuba/web/rpc/v1/endpoint_trace_item_attribute_names.py index b08268bfe1..7870017188 100644 --- a/snuba/web/rpc/v1/endpoint_trace_item_attribute_names.py +++ b/snuba/web/rpc/v1/endpoint_trace_item_attribute_names.py @@ -172,7 +172,7 @@ def _build_response( attributes = convert_to_attributes(res, req.type) page_token = ( PageToken(offset=req.page_token.offset + len(attributes)) - if req.page_token.HasField("offset") + if req.page_token.HasField("offset") or len(attributes) == 0 else PageToken( filter_offset=TraceItemFilter( comparison_filter=ComparisonFilter( diff --git a/tests/web/rpc/v1/test_endpoint_trace_item_attribute_names.py b/tests/web/rpc/v1/test_endpoint_trace_item_attribute_names.py index 367d73f5da..08e0c327f5 100644 --- a/tests/web/rpc/v1/test_endpoint_trace_item_attribute_names.py +++ b/tests/web/rpc/v1/test_endpoint_trace_item_attribute_names.py @@ -210,6 +210,26 @@ def test_with_page_token_offset(self) -> None: done += at_a_time assert expected_attributes == [] + def test_empty_results(self) -> None: + req = TraceItemAttributeNamesRequest( + meta=RequestMeta( + project_ids=[1, 2, 3], + organization_id=1, + cogs_category="something", + referrer="something", + start_timestamp=Timestamp( + seconds=int((BASE_TIME - timedelta(days=1)).timestamp()) + ), + end_timestamp=Timestamp( + seconds=int((BASE_TIME + timedelta(days=1)).timestamp()) + ), + ), + type=AttributeKey.Type.TYPE_STRING, + value_substring_match="this_definitely_doesnt_exist_93710", + ) + res = EndpointTraceItemAttributeNames().execute(req) + assert res.attributes == [] + def test_page_token_offset_filter(self) -> None: expected_attributes = []