A filter narrows the query, not the page that was taken - #101
Merged
Conversation
State and verdict were applied to the page after the database had produced it, so a match beyond the first page left that page empty and `total` counted rows the filter removed. Both now narrow the query.
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.
Filtering the manager's submissions list by state or verdict answered with an
empty first page and the match on the second. Reported from production on
2026-09-08: one submission matched, and page one said nothing matches the
filters.
What was wrong
ManagerReadService.ListSubmissionsAsynctook the page from the database andthen filtered it in memory:
So a filter answered with whichever matches happened to fall on the page that
was asked for. Two consequences, both visible in the report:
totalcounted rows the filter would have removed, so the pager offered pagesthat were empty by construction.
The comment's premise is what made it look reasonable, and it is not true: EF
Core translates the correlated subquery this needs.
ListRunnersAsync, twentylines below, already filters its state in the query — this listing was the
outlier.
What changed
State and verdict narrow the query, before
CountAsyncand before paging. Thesubquery makes the same choice
Scoring.Currentdoes — the highest attemptnumber — and says so, because a row filtered on one attempt and rendered from
another would be a subtler version of this bug.
Two behaviours are kept deliberately: a submission with no job at all still reads
as
queued, which is whatProjectreports for one; and a state the product hasno name for now matches nothing rather than being read as the default, which
would answer a question nobody asked.
Verified
dotnet build, zero warnings. Three new tests inPageQueryTests.cs, runagainst the Testcontainers PostgreSQL the suite uses:
totalis the filtered count;
answers empty;
Sabotaged to prove they bite: with the filters put back after paging, all
three fail — the first on
Assert.Singleagainst an empty page, which is thescreen the report came in about.
That the tests pass at all is also the evidence that the subquery translates: an
untranslatable one throws rather than returning the wrong rows.