Skip to content

HYPERFLEET-1280 - refactor: rename pagination and ordering query params#253

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-hyperfleet:mainfrom
sherine-k:HYPERFLEET-1280
Jun 25, 2026
Merged

HYPERFLEET-1280 - refactor: rename pagination and ordering query params#253
openshift-merge-bot[bot] merged 1 commit into
openshift-hyperfleet:mainfrom
sherine-k:HYPERFLEET-1280

Conversation

@sherine-k

Copy link
Copy Markdown
Contributor

Summary

This is a follow-up for openshift-hyperfleet/hyperfleet-api-spec#63

Aligns query parameter names with the updated OpenAPI spec (v1.0.24).

  • Rename pageSize query parameter to size

  • Rename orderBy query parameter to order

  • Remove backward-compatible pageSize fallback logic

  • Remove OrderDirection enum from API docs

  • Rename ListArguments.OrderBy field to Order

  • Update integration tests and documentation to match

  • Bump hyperfleet-api-spec from v1.0.23 to v1.0.24

  • HYPERFLEET-1280

Test Plan

  • Unit tests added/updated
  • make test-all passes
  • make lint passes
  • Helm chart changes validated with make test-helm (if applicable)
  • Deployed to a development cluster and verified (if Helm/config changes)
  • E2E tests passed (if cross-component or major changes)

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Updated list and pagination requests to use size and order parameters consistently.
    • Default sorting now applies when no valid ordering is provided.
  • Bug Fixes

    • Improved handling of pagination and sorting inputs across cluster, node pool, channel, and adapter status lists.
    • Legacy pageSize and orderBy inputs are no longer relied on in updated flows.
  • Documentation

    • Refreshed API docs to match the new query parameter names and ordering behavior.

Walkthrough

The cluster list API docs now describe size and order query parameters instead of pageSize and orderBy. ListArguments was renamed to use Order, and list parsing now reads size and order directly with updated default ordering. The related unit and integration tests were updated to use the new parameter names and request fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: renaming pagination and ordering query params.
Description check ✅ Passed The description aligns with the diff and accurately describes the OpenAPI v1.0.24 parameter rename.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sec-02: Secrets In Log Output ✅ Passed No changed non-test source file logs token/password/credential/secret; pkg/services/generic.go and types.go have no log calls.
No Hardcoded Secrets ✅ Passed No hardcoded credentials, embedded secrets, long base64 blobs, or credentialed URLs were introduced in the modified files (CWE-798).
No Weak Cryptography ✅ Passed No banned crypto primitives, custom crypto, or secret comparisons found in the diff; changes are docs/tests/query-param renames and a spec bump.
No Injection Vectors ✅ Passed PASS: No new CWE-89/78/79/502 path in changed code; order still flows through db.ArgsToOrderBy/getField validation, and the rest are docs/tests.
No Privileged Containers ✅ Passed No privileged:true/host* or allowPrivilegeEscalation:true found; Dockerfile uses USER root only briefly to install make, then drops to 1001 (non-root).
No Pii Or Sensitive Data In Logs ✅ Passed No changed lines add slog/logr/zap/fmt.Print/t.Logf or raw body/PII fields; diffs are param renames only, so no CWE-532 exposure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread pkg/services/generic.go
@@ -141,8 +141,8 @@ func (s *sqlGenericService) buildPreload(listCtx *listContext, d *dao.GenericDao
}

func (s *sqlGenericService) buildOrderBy(listCtx *listContext, d *dao.GenericDao) (bool, *errors.ServiceError) {

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.

Should we change the name to buildOrder?

Then you would also subsequently need to change https://github.com/openshift-hyperfleet/hyperfleet-api/blob/main/pkg/services/generic.go#L100C5-L100C17

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.

As this is an non-exported function, I don't think matters that much, let's move on with the PR

@rh-amarin rh-amarin marked this pull request as ready for review June 25, 2026 18:20
@rh-amarin

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rh-amarin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hyperfleet-ci-bot

Copy link
Copy Markdown

Risk Score: 1 — risk/low

Signal Detail Points
PR size 245 lines (>200) +1
Sensitive paths none +0
Test coverage Tests cover changed packages +0

Computed by hyperfleet-risk-scorer

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/services/types.go (1)

91-115: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not drop pageSize until linked clients move to size.

Lines 91-115 stop reading pageSize, and the updated tests now assert that legacy param is ignored. Sentinel, Broker, and Adapter still construct list requests with PageSize, so those callers will silently fall back to the default page size of 20 instead of the requested value. Keep a temporary pageSize alias here, or land the downstream client updates first.

Suggested compatibility patch
-	// Validate size parameter
-	if v := strings.Trim(params.Get("size"), " "); v != "" {
-		size, err := strconv.ParseInt(v, 10, 64)
+	// Validate size parameter
+	sizeParam := strings.Trim(params.Get("size"), " ")
+	if sizeParam == "" {
+		sizeParam = strings.Trim(params.Get("pageSize"), " ")
+	}
+	if sizeParam != "" {
+		size, err := strconv.ParseInt(sizeParam, 10, 64)
 		if err != nil {
 			return nil, errors.New(
 				errors.CodeValidationFormat,
 				"Invalid size parameter: must be a positive integer",
 			)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/services/types.go` around lines 91 - 115, The size parsing in the
list-args validation now only reads "size", which breaks existing callers still
sending "pageSize" from Sentinel, Broker, and Adapter. Update the parameter
handling in the validation logic to temporarily accept "pageSize" as an alias
(or preserve the legacy fallback) in the same place where size is parsed, so
ListArgs.Size is populated correctly for both names until downstream clients are
migrated.

Source: Linked repositories

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/services/types_test.go`:
- Around line 290-293: The `pageSize` test case in `types_test.go` is locking in
a breaking contract change while `PageSize` is still used by linked clients.
Update the `queryParams`/list parameter handling so the `PageSize` field remains
temporarily compatible (or otherwise coordinated with downstream client updates)
in the relevant request parsing path, and keep the behavior covered by the
existing test around the list request types.

In `@test/integration/clusters_test.go`:
- Around line 205-208: Coordinate the `pageSize` query-contract change across
all downstream consumers before finalizing this test update: `GetClustersParams`
in the cluster integration tests should match the new API shape, but the
Sentinel, Broker, and Adapter client request builders and assertions still rely
on `PageSize` and `pageSize` expectations. Update the affected client helpers
and related tests to use the current pagination fields consistently, and only
keep references that align with the renamed contract so `GetClustersParams` and
the other `Get*Params` usages stay in sync.

---

Outside diff comments:
In `@pkg/services/types.go`:
- Around line 91-115: The size parsing in the list-args validation now only
reads "size", which breaks existing callers still sending "pageSize" from
Sentinel, Broker, and Adapter. Update the parameter handling in the validation
logic to temporarily accept "pageSize" as an alias (or preserve the legacy
fallback) in the same place where size is parsed, so ListArgs.Size is populated
correctly for both names until downstream clients are migrated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: d2db453f-28af-491c-9a7f-cdebc4fe2c95

📥 Commits

Reviewing files that changed from the base of the PR and between 177f746 and 4017e54.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum, !**/go.sum
📒 Files selected for processing (10)
  • docs/api-resources.md
  • go.mod
  • pkg/services/CLAUDE.md
  • pkg/services/generic.go
  • pkg/services/types.go
  • pkg/services/types_test.go
  • test/integration/adapter_status_test.go
  • test/integration/channels_test.go
  • test/integration/clusters_test.go
  • test/integration/node_pools_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment on lines 290 to +293
{
name: "non-numeric pageSize returns error",
queryParams: url.Values{"pageSize": []string{"xyz"}},
expectError: true,
errorContains: "Invalid pageSize parameter",
errorCode: "HYPERFLEET-VAL-003",
name: "pageSize is ignored (no longer a valid parameter)",
queryParams: url.Values{"pageSize": []string{"50"}},
expectError: false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Blocking contract break: pageSize is now ignored while linked clients still send it.

This test locks in silent fallback to the default page size for callers that still use the old parameter. The linked hyperfleet-sentinel, hyperfleet-broker, and hyperfleet-adapter clients still populate PageSize, so their list calls will stop honoring requested pagination and degrade to size=20 semantics until those repos ship coordinated updates. Either preserve temporary compatibility here or merge this only with the downstream client changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/services/types_test.go` around lines 290 - 293, The `pageSize` test case
in `types_test.go` is locking in a breaking contract change while `PageSize` is
still used by linked clients. Update the `queryParams`/list parameter handling
so the `PageSize` field remains temporarily compatible (or otherwise coordinated
with downstream client updates) in the relevant request parsing path, and keep
the behavior covered by the existing test around the list request types.

Source: Linked repositories

Comment on lines +205 to +208
size := openapi.QueryParamsSize(5)
params := &openapi.GetClustersParams{
Page: &page,
PageSize: &pageSize,
Page: &page,
Size: &size,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Coordinate downstream client updates before removing pageSize.

pkg/services/types_test.go:260-320 now treats pageSize as invalid/ignored, but the linked Sentinel, Broker, and Adapter clients still build cluster and node pool requests with Get*Params{PageSize: ...} and still assert pageSize in their tests. Shipping this rename by itself leaves those consumers on the stale query contract from v1.0.23.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integration/clusters_test.go` around lines 205 - 208, Coordinate the
`pageSize` query-contract change across all downstream consumers before
finalizing this test update: `GetClustersParams` in the cluster integration
tests should match the new API shape, but the Sentinel, Broker, and Adapter
client request builders and assertions still rely on `PageSize` and `pageSize`
expectations. Update the affected client helpers and related tests to use the
current pagination fields consistently, and only keep references that align with
the renamed contract so `GetClustersParams` and the other `Get*Params` usages
stay in sync.

Source: Linked repositories

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants