ref(resolvers): inline the trace item table resolver - #8454
Open
MeredithAnya wants to merge 1 commit into
Open
Conversation
| ) -> PageToken: | ||
| num_rows_in_response = len(response[0].results) if response else 0 | ||
| if time_window is not None: | ||
| if num_rows_returned > request.limit: |
Contributor
There was a problem hiding this comment.
Bug: The pagination logic at _get_page_token incorrectly compares num_rows_returned with request.limit (which can be 0), instead of the effective query limit, causing pagination to fail.
Severity: HIGH
Suggested Fix
The pagination logic should use the effective limit applied to the database query, not the raw request.limit value. When request.limit is 0, the comparison should use the default row limit (e.g., _DEFAULT_ROW_LIMIT) to correctly determine if there are more pages.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: snuba/web/rpc/v1/endpoint_trace_item_table.py#L799
Potential issue: When a flextime-routed query is made without an explicit `limit`, the
`request.limit` defaults to 0. The database query correctly uses a default limit (e.g.,
10,001 rows), but the pagination logic in `_get_page_token` compares the number of rows
returned against the original `request.limit` of 0. This `num_rows_returned > 0`
comparison will always be true if any data is returned, causing the system to
incorrectly issue a next-page token for the same time window. This prevents pagination
from advancing to subsequent time windows or ever finishing, leading to incomplete data
or infinite loops for the client.
Did we get this right? 👍 / 👎 to inform future reviews.
MeredithAnya
added this pull request to stack #8456
September 9, 2026 23:52
pbhandari
approved these changes
Sep 10, 2026
ResolverTraceItemTableEAPItems was the last concrete resolver. Move the resolver module body into endpoint_trace_item_table.py and turn resolve() into _query_trace_item_table, following 76d1fed. resolvers/__init__.py now declares no resolver classes; the abstraction itself is removed in the next change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MeredithAnya
force-pushed
the
meredith/convert-resolver-trace-item-table
branch
from
September 10, 2026 19:50
39c536a to
ea67d2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
ref(resolvers): remove unused resolver declarationsref(resolvers): inline the trace item stats resolverref(resolvers): inline the time series resolverref(resolvers): inline the trace item table resolverref(resolvers): remove the TraceItemDataResolver abstractionWhat
Same transformation as #8452 and #8453, applied to
EndpointTraceItemTable.ResolverTraceItemTableEAPItemswas the last concrete resolver.Moves the resolver module body into
endpoint_trace_item_table.pyand turnsresolve()into_query_trace_item_tablereadingself.routing_decision.This is the biggest of the three — the resolver was 897 lines, so
endpoint_trace_item_table.pyends up around 1200. It's a pure move: nothing in the pasted body changed, so the added lines should diff cleanly against the deleted file.After this,
resolvers/__init__.pydeclares no resolver classes at all. The abstraction itself comes out in the next PR.Tests
Import/patch-target updates only.
pytest tests/web/rpc/v1/test_endpoint_trace_item_table/ test_storage_routing.py test_cross_item_local_join.py→ 198 passed.mypy snuba/web/rpc/clean.🤖 Generated with Claude Code