Reject --before combined with --first

NewCursorFromFlags validated --first/--last, --after/--before, and
--after/--last as mutually exclusive, but missing the symmetric
--first/--before guard. Passing --first with --before fell into the
backward branch, where size defaulted from the unset --last and the
direction silently flipped to Tail, discarding --first and reversing
pagination. Reject the combination up front like the other invalid
pairings.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-09 16:52:20 +02:00
parent 60a1b1c661
commit 87e95e8993

View File

@@ -87,6 +87,10 @@ func NewCursorFromFlags[F page.OrderField](
return nil, fmt.Errorf("--after cannot be combined with --last")
}
if pf.Before != "" && pf.First > 0 {
return nil, fmt.Errorf("--before cannot be combined with --first")
}
var (
size int
from *page.CursorKey