deployment list applies --limit before --sort, breaking top-N sort #605

Closed
opened 2026-08-08 10:27:41 +00:00 by the.auditor · 1 comment
Owner

In internal/tpagectl/deployment/list.go the --limit truncation runs before --sort:

if limit := cmd.Int("limit"); limit > 0 && limit < len(deployments) {
    deployments = deployments[:limit]
}
if sortCol := cmd.String("sort"); sortCol != "" {
    deployments, err = sortDeployments(deployments, sortCol)
    ...
}

As a result --sort only reorders the already-truncated subset and cannot select the top N across the full set. E.g. deployment list --limit 5 --sort deployed takes the first 5 in server order, then sorts those 5 — not the 5 oldest/newest overall.

Sort first, then apply the limit.

See #604

In `internal/tpagectl/deployment/list.go` the `--limit` truncation runs before `--sort`: if limit := cmd.Int("limit"); limit > 0 && limit < len(deployments) { deployments = deployments[:limit] } if sortCol := cmd.String("sort"); sortCol != "" { deployments, err = sortDeployments(deployments, sortCol) ... } As a result `--sort` only reorders the already-truncated subset and cannot select the top N across the full set. E.g. `deployment list --limit 5 --sort deployed` takes the first 5 in server order, then sorts those 5 — not the 5 oldest/newest overall. Sort first, then apply the limit. See https://git.lan.thwap.org/thwap/thwap-pagesd/pulls/604
Owner

Fixed in #634: deployment list sorts before applying --limit, so the limited subset reflects the requested sort order (regression test added).

Fixed in #634: `deployment list` sorts before applying `--limit`, so the limited subset reflects the requested sort order (regression test added).
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd#605
No description provided.