Skip to content

feat(spec): support page_index params in the request body - #526

Open
BlueLabelscotch wants to merge 2 commits into
mainfrom
feat/page-index-body-paging
Open

BlueLabelscotch wants to merge 2 commits into
mainfrom
feat/page-index-body-paging

Conversation

@BlueLabelscotch

@BlueLabelscotch BlueLabelscotch commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #509

What

  • New opt-in paging.page_params_in: body (default query). With page_index, the index and size params are merged into the JSON request body instead of the query string, leaving other body keys intact.
  • Validated in pkg/registry/checks.go: only page_index, and only POST/PUT/PATCH.
  • At runtime, a non-object request body (e.g. a raw or array body) returns an error rather than being overwritten.

Testing

No unit tests yet. Checked manually against a live account:

  • list gitops_repocred sent pageIndex/pageSize in the body and got a 200 at project, org and account scope.
  • With a throwaway local spec change (not committed), list gitops_repository with body paging and page size 2 fetched pageIndex 0 then 1 and returned all 3 items; a hard-coded body pageSize was overridden.
  • go test passes for pkg/endpoint, pkg/registry, pkg/spec.

Follow-up

Module PR to adopt it in list gitops_repocred (replacing the fixed pageSize: "1000"), after this lands.

@augmentcode

augmentcode Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

CLI Grammar Review · session (Harness team members only) · 55eb7df

No CLI grammar changes as of 55eb7df.

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

Review completed with 5 suggestions.

Reviewed commit: ef20ff6

Comment thread pkg/spec/gitops.spec.yaml Outdated
endpoint:
method: POST
path: /gitops/api/v1/repocreds
items_expr: it.content ?? []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

items_expr passes each credential object through unchanged, and the API response schema includes passwords and private keys. JSON and JSONL output ignore columns, so any secret values the API returns would be written unredacted to stdout or the output file.

Severity: high


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/registry/checks.go
return fmt.Errorf("command %q: paging requires page_size_param", command)
}
}
switch pg.PageParamsIn {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

validatePaging returns early for flat_list, so this switch never rejects page_params_in: body or an invalid value on that strategy. A POST flat_list spec can therefore register successfully with body paging enabled even though it never sends the paging parameters.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

req.QueryParams[indexParam] = strconv.Itoa(pageIndex)
if pg.PageSizeParam != "" && pageSize > 0 {
req.QueryParams[pg.PageSizeParam] = strconv.Itoa(pageSize)
if pg.PageParamsIn == spec.PageParamsInBody {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

InjectPaging has no regression test that checks both sides of a page boundary and verifies that body paging overwrites only the paging keys. That leaves stale page values or dropped filters undetected by the existing suite; AGENTS.md calls for focused tests of request-body transformations and boundary cases.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml Outdated
searchTerm: 'flags.search != "" ? flags.search : nil'
agentIdentifier: 'flags.agent != "" ? flags.agent : nil'
paging:
paging_strategy: page_index

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

list gitops_repocred declares a documented API total but leaves countable off, so the CLI rejects both --all and --count. Users who need the full list still have to walk pages manually.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Comment thread pkg/spec/gitops.spec.yaml Outdated
agentIdentifier: 'flags.agent != "" ? flags.agent : nil'
paging:
paging_strategy: page_index
page_params_in: body

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

list gitops_repocred adopts the new core paging feature in the same PR, but AGENTS.md requires a separate module PR unless the change is needed for compatibility. Is there a compatibility reason to bundle it here, rather than following the split described in #509 and previously noted in #511?

Severity: low


🤖 Was this useful? React with 👍 or 👎

@BlueLabelscotch
BlueLabelscotch force-pushed the feat/page-index-body-paging branch from ef20ff6 to 09a134b Compare November 20, 2026 18:45
@BlueLabelscotch

Copy link
Copy Markdown
Collaborator Author

cosmos review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

Review completed with 2 suggestions.

Reviewed commit: 55eb7df

Comment thread pkg/registry/checks.go
if err := validatePaging(cs.Command, ep.Paging); err != nil {
return err
}
if ep.Paging.PageParamsIn == spec.PageParamsInBody {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

validateEndpointConstraints accepts body paging with body_fn, but the paging path builds the request without calling that function. A POST list spec can therefore silently drop filters from body_fn, and a raw or array body returned by the function never reaches the new type check.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

body = map[string]any{}
req.Body = body
}
body[indexParam] = pageIndex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

HTTPFetchFn runs validators_endpoint before InjectPaging inserts or overwrites the page index and size in the body. A validator can reject a request whose final body would be valid, or approve a body whose paging values are replaced before it is sent.

Severity: medium


🤖 Was this useful? React with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

page_index paging: support pageIndex/pageSize in the request body

1 participant