[CFX-7834] refactor(pipeline): validate count flags at parse time - #859
Merged
Merged
Conversation
|
🎫 Jira: |
ajalon1
force-pushed
the
aj/CFX-7834-countflags-pipelines
branch
from
August 27, 2026 20:49
335411f to
23c9407
Compare
ajalon1
marked this pull request as ready for review
August 27, 2026 21:15
sunny2get
approved these changes
Aug 31, 2026
sunny2get
left a comment
Contributor
There was a problem hiding this comment.
LGTM - thanks for covering this.
Migrates the pipeline family's count flags onto internal/countflags from the base stack: - --limit -> countflags.PositiveInt on pipeline list (default 50), version/run/image/input/schedule list (default 100) - --offset -> countflags.NonNegativeInt on all six list commands - --tail on pipeline run task logs -> countflags.NonNegativeInt, keeping 0 as "no limit" These commands previously did no validation at all, so --limit 0/-1 and negative offsets went straight to the API; they are now rejected during flag parsing with cobra's standard "invalid argument" message, before any request is made. Adds invalid-limit/invalid-offset reject tests per list command and an invalid-tail test for task logs, in the existing runCmd style. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
ajalon1
force-pushed
the
aj/CFX-7834-countflags-pipelines
branch
from
August 31, 2026 17:34
23c9407 to
7d67898
Compare
ajalon1
added a commit
to ajalon1/derkeley
that referenced
this pull request
Aug 31, 2026
Today's countflags migration (CFX-7834, datarobot-oss#858/datarobot-oss#859/datarobot-oss#860) is documented in docs/development/flags.md but had no reviewer-facing rule — a new count-like flag validated in RunE instead of at parse time would sail through review. Adds the parse-time-validation rule plus its documented exception (0 as a "use default" sentinel, per the workload config --port/--replicas precedent).
cdevent
pushed a commit
that referenced
this pull request
Sep 3, 2026
Migrates the pipeline family's count flags onto internal/countflags from the base stack: - --limit -> countflags.PositiveInt on pipeline list (default 50), version/run/image/input/schedule list (default 100) - --offset -> countflags.NonNegativeInt on all six list commands - --tail on pipeline run task logs -> countflags.NonNegativeInt, keeping 0 as "no limit" These commands previously did no validation at all, so --limit 0/-1 and negative offsets went straight to the API; they are now rejected during flag parsing with cobra's standard "invalid argument" message, before any request is made. Adds invalid-limit/invalid-offset reject tests per list command and an invalid-tail test for task logs, in the existing runCmd style. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RATIONALE
The pipeline list commands did no flag validation at all — the workload family validated, this family didn't, so the same mistake failed differently depending on which command ate it. The latent bugs this closes:
--limit 0(or negative) silently returned fewer rows than asked. The old query builder omitted thelimitparam when it was<= 0, so the server's default page size applied: a script requesting 100 rows got the default, with no error and nothing in the output saying so.--offsetsilently restarted results from the beginning. Same omission: the param was dropped, so every page request returned page 1. A paging loop with a computed offset that dipped negative re-fetched duplicate rows forever instead of failing.pipeline run task logs --tail -5senttail_lines=-5to the live-log endpoint. The negative value was forwarded verbatim once the flag was set, producing a server-side failure mid-command — after authentication, deep past the point of feedback.Migrating onto
internal/countflags(from part 1, #858) makes the fix mechanical rather than per-command.CHANGES
--limit->countflags.PositiveIntondr pipeline list(default 50) andversion/run/image/input/schedule list(default 100).--offset->countflags.NonNegativeInt(default 0) on all six list commands.--tailondr pipeline run task logs->NonNegativeInt, keeping 0 as "no limit".--tailtest, in the existingrunCmdstyle.TESTING
task lint(all GOOS legs) andtask test(race + coverage) pass.NOTES
Part 2/4 of a stacked review. Based on #858 (base = its branch), so this diff shows only the pipeline changes. Invalid values now error at parse time instead of reaching the API. (Result truncation for large limits is a separate fix, part 4 #861.)
Note
Low Risk
CLI-only flag validation and tests; behavior is stricter for invalid pagination/tail values with no changes to auth or server contracts beyond not sending bad query params.
Overview
Pipeline list commands and run task logs now validate pagination and tail flags during Cobra parsing via
internal/countflags, instead of plainIntVarflags that could reach the API with bad values.--limitusesPositiveInt(rejects0and negatives) onpipeline list, and on image/input/run/schedule/version list commands with the same defaults as before.--offsetusesNonNegativeInton those list commands.pipeline run task logs --tailusesNonNegativeIntso negatives fail before auth/network;--tail 0remains “no limit.”Each touched command gains tests that invalid
--limit,--offset, or--tailfail at parse time with the expected error messages.Reviewed by Cursor Bugbot for commit 23c9407. Configure here.