feat(cli): stop refusing bd list --max-rows under --proxied-server

The refusal was a fact about the query path, not about the flag: the proxied
repository path threaded no MaxRows, so honoring the cap there would have been
silence and rejecting it was the honest answer (be-x42v.4). That path threads
one now, so `bd list` moves to addRoutedMaxRowsFlag — the help text `bd dep tree`
already uses — and the cap fires with the direct route's message and exit code.

The two integration cases that pinned the refusal now pin the firing, naming the
source so a cap that fired for the wrong reason still fails.
This commit is contained in:
CI Bot 2026-08-08 06:59:00 +00:00
commit 3b23859224
4 changed files with 36 additions and 22 deletions

View file

@ -191,10 +191,16 @@ func runListCore(cmd *cobra.Command, _ []string) error {
}
if usesProxiedServer() {
if err := rejectResolvedMaxRowsUnderProxiedServer(in.MaxRows); err != nil {
return err
}
// The cap USED to be rejected here: the proxied query path threaded no
// MaxRows, so honoring it would have been silence. It threads one now
// (internal/storage/domain/db sizes its bound and enforces the cap
// through the same two functions the store seam uses), so this route
// answers *ErrTooManyRows the same way the direct route below does —
// same message, same exit code.
if err := runListProxiedServer(cmd, rootCtx, in); err != nil {
if capErr := handleMaxRowsError(err); capErr != nil {
return capErr
}
return HandleError("%v", err)
}
return nil
@ -499,7 +505,8 @@ func init() {
listCmd.Flags().Bool("ready", false, "Show only ready issues (no active blockers, same semantics as bd ready)")
// Defensive row cap (be-x42v): exits 2 on overage, default disabled.
addMaxRowsFlag(listCmd)
// ROUTED, not direct-only: both routes thread the cap now.
addRoutedMaxRowsFlag(listCmd)
// Note: --json flag is defined as a persistent flag in main.go, not here
rootCmd.AddCommand(listCmd)

View file

@ -312,9 +312,7 @@ func gatherListInput(cmd *cobra.Command) (listInput, error) {
//
// Resolving it HERE also means it is resolved exactly once per invocation.
// resolveMaxRowsEnvOnly warns on a malformed BEADS_MAX_ROWS every time it
// runs, so runListCore's proxied-server refusal reads the value this
// resolved (rejectResolvedMaxRowsUnderProxiedServer) rather than resolving
// a second time and warning twice.
// runs, so a second resolve downstream would warn twice.
maxRows, maxRowsSource, err := resolveMaxRows(cmd)
if err != nil {
return in, err

View file

@ -728,26 +728,34 @@ func TestProxiedServerList(t *testing.T) {
}
})
// The proxied repository path (internal/storage/domain/db) doesn't
// thread MaxRows through the UOW pipeline, so an explicit cap must be
// rejected rather than silently going unenforced (be-x42v.4 follow-up).
t.Run("reject_max_rows_flag", func(t *testing.T) {
// The cap is HONORED on this route now. It used to be rejected outright,
// because the proxied repository path (internal/storage/domain/db) read no
// MaxRows at all and honoring it would have meant silence (be-x42v.4). The
// answer is the cap firing, with the same text and the same exit code the
// direct route prints.
t.Run("max_rows_flag_fires", func(t *testing.T) {
out := bdProxiedListFail(t, bd, p, "--max-rows", "1")
if !strings.Contains(out, "not supported in proxied-server mode") {
t.Errorf("expected --max-rows proxied-server rejection, got: %s", out)
if strings.Contains(out, "not supported in proxied-server mode") {
t.Fatalf("--max-rows is refused under --proxied-server; the cap threads this route now: %s", out)
}
if !strings.Contains(out, "too many rows") || !strings.Contains(out, "--max-rows=1") {
t.Errorf("expected the cap to fire naming its source, got: %s", out)
}
})
t.Run("reject_max_rows_env", func(t *testing.T) {
t.Run("max_rows_env_fires", func(t *testing.T) {
fullArgs := []string{"list"}
stdout, stderr, err := bdProxiedRunBuffersWithEnv(t, bd, p.dir,
[]string{"BEADS_MAX_ROWS=1"}, fullArgs...)
if err == nil {
t.Fatalf("expected BEADS_MAX_ROWS under proxied-server to fail, but it succeeded:\nstdout:\n%s\nstderr:\n%s", stdout, stderr)
t.Fatalf("expected BEADS_MAX_ROWS under proxied-server to trip the cap, but it succeeded:\nstdout:\n%s\nstderr:\n%s", stdout, stderr)
}
out := stdout + stderr
if !strings.Contains(out, "not supported in proxied-server mode") {
t.Errorf("expected BEADS_MAX_ROWS proxied-server rejection, got: %s", out)
if strings.Contains(out, "not supported in proxied-server mode") {
t.Fatalf("BEADS_MAX_ROWS is refused under --proxied-server; the cap threads this route now: %s", out)
}
if !strings.Contains(out, "too many rows") || !strings.Contains(out, "BEADS_MAX_ROWS=1") {
t.Errorf("expected the cap to fire naming its source, got: %s", out)
}
})

View file

@ -36,11 +36,12 @@ func addMaxRowsFlag(cmd *cobra.Command) {
// both routes, so the help text must not repeat the proxied-server refusal above.
//
// It exists because that refusal is a fact about a command's implementation
// rather than about the flag: `bd list --max-rows --proxied-server` errors out
// because the unit-of-work query path threads no cap, and a command whose cap
// lives on an issueops request threads one everywhere. `bd dep tree` is the
// first; the next one to move onto a role calls this instead of the function
// above and deletes its rejectMaxRowsUnderProxiedServer call in the same edit.
// rather than about the flag: a command whose cap reaches a query path that
// threads one is honored on both routes. `bd dep tree` was the first and `bd
// list` the second — its cap used to be rejected under --proxied-server because
// the unit-of-work query path read no MaxRows at all. The next command to move
// onto a role that threads it calls this instead of the function above and
// deletes its rejectMaxRowsUnderProxiedServer call in the same edit.
func addRoutedMaxRowsFlag(cmd *cobra.Command) {
cmd.Flags().Int(maxRowsFlagName, 0,
"Hard upper bound on rows returned. Returns a non-zero exit (code 2) "+