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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user