Skip to content

flows: support pagination in kosli list flows #978

Description

@dangrondahl

Problem

kosli list flows calls GET /api/v2/flows/{org} with no page/per_page and renders the full array. On orgs with many flows this is slow and there is no way to page through results. Pagination was explicitly deferred in #943 ("Pagination / large-list latency ... needs a server-side change first; tracked separately") because the endpoint did not support it.

API capability now available

The server-side change has landed. GET /api/v2/flows/{org} now accepts optional pagination, following the same pattern as the trails endpoint:

  • page (int, default 1, >= 1)
  • per_page (int, 1..100)
  • When per_page is omitted the endpoint returns a plain array (unchanged, backwards compatible with the current CLI).
  • When per_page is sent it returns an envelope: { "data": [...], "pagination": { "total", "page", "per_page", "page_count" } }.
  • FlowList items now also include an id field.

Proposed change

Bring kosli list flows in line with kosli list trails / kosli list artifacts, which already support pagination:

  1. Embed the shared listOptions in listFlowsOptions and call addListFlags(cmd, &o.listOptions) (adds --page, default 1, and --page-limit/-n, default 15). Add a validate() that calls o.listOptions.validate(cmd).
  2. Always send page and per_page as query params in cmd/kosli/listFlows.go (sending per_page switches the server to the envelope response).
  3. Update printFlowsListAsTable to unmarshal the {data, pagination} envelope (like listTrailsResponse/printTrailsListAsTable), render rows from response.Data, and append a Showing page X of Y, total Z items footer. Include the page number in the "No flows were found" message.

⚠️ Shorthand conflict to resolve

listFlows.go currently binds -n to --name (StringVarP(&o.name, "name", "n", ...)), but addListFlags binds -n to --page-limit. These might collide in the future. Options: drop the -n shorthand from --name (keep --name/-i long forms), or wire the pagination flags manually without -n. Decide and call it out in the PR — this is the one non-mechanical decision. We could use -N

Out of scope

Definition of Done

  • --page and --page-limit flags added to kosli list flows and wired into the request URL
  • Response parsing handles the {data, pagination} envelope and prints a pagination footer
  • -n shorthand conflict resolved (documented in PR)
  • kosli list flows --help documents the new flags
  • Integration tests cover paging (page 1, page 2, page-limit, empty page)
  • Existing --name/--ignore-case behaviour still works

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update go code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions