Skip to content

A session can be in the sessions page and not in its total #1337

Description

@DEENUU1

SessionService.list_sessions can answer with a session in items that is not
counted in total.

Since #1256 (released 0.0.324) "open" means is_active AND expires_at > now(),
and app/repositories/session.py builds that predicate per statement. The page
query and the count query are separate statements, so each evaluates its own
now(): a session that reaches expires_at between them is open to one and
expired to the other, and the response then breaks the pagination invariant with
no concurrent write involved.

Narrow — a session has to expire inside the gap between two queries — but the fix
is small and local: one cutoff computed by the caller and passed to both
statements, or a transaction-stable database timestamp.

How you would know it was fixed

A test that pins one cutoff and asserts len(items) agrees with total across
it. Today the predicate cannot be pinned from outside, which is the thing to
change.

Found reviewing #1279 (Codex, P2), the pull request that introduced the
predicate.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingeffort:sUnder a dayseverity:lowClean-up, dead code, minor duplication

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions