Skip to content

fix: rule-engine pagination#40

Merged
rnovatorov merged 2 commits into
v3from
rnovatorov/v3
May 15, 2026
Merged

fix: rule-engine pagination#40
rnovatorov merged 2 commits into
v3from
rnovatorov/v3

Conversation

@rnovatorov
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes pagination behavior for the rule-engine list endpoint, which (unlike sites/devices) is a legacy unpaginated endpoint that rejects limit/offset query parameters and omits total_count. The CLI now skips pagination params on the first request, detects the legacy case from a missing/zero total_count, and stops iterating; otherwise it falls back to the regular offset/limit pagination loop. It also surfaces server error messages (via parseRespErrorMessage) instead of a generic "Unexpected response status".

Changes:

  • Defer setting limit/offset until the second pagination request, and break early if the first response has no total_count (legacy unpaginated endpoint), synthesizing total_count from the items length when needed.
  • Make total_count optional in paginateRespProcesor.Process and improve error message on non-200 responses.
  • Update existing fixtures (sites, rule-engine rules) to drop the first-page limit/offset query, and add a new fixture covering the legacy unpaginated rule-engine response.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

File Description
internal/app/enaptercli/cmd_base_pagination.go Core pagination change: defer limit/offset to subsequent requests, detect legacy unpaginated responses, synthesize total_count, use parseRespErrorMessage, and tolerate missing total_count.
internal/app/enaptercli/testdata/http_req_resp/site_list_without_site_id/req_0 Update expected first-request URL to drop limit/offset.
internal/app/enaptercli/testdata/http_req_resp/rule_engine_rule_list/req_0 Same update for the rule-engine rule list fixture.
internal/app/enaptercli/testdata/http_req_resp/rule_engine_rule_list_legacy_unpaginated/{cmd.tmpl,req_0,resp_0,out} New fixture exercising the legacy unpaginated rule-engine response (no total_count).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/app/enaptercli/cmd_base_pagination.go Outdated
Comment thread internal/app/enaptercli/cmd_base_pagination.go Outdated
@rnovatorov rnovatorov force-pushed the rnovatorov/v3 branch 3 times, most recently from a4141f6 to 0fb93e1 Compare May 14, 2026 00:46
@rnovatorov rnovatorov requested a review from Copilot May 14, 2026 00:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread internal/app/enaptercli/cmd_base_pagination.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread internal/app/enaptercli/cmd_base_pagination.go Outdated
Comment thread internal/app/enaptercli/cmd_base_pagination.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@rnovatorov rnovatorov merged commit dd96c64 into v3 May 15, 2026
6 checks passed
@rnovatorov rnovatorov deleted the rnovatorov/v3 branch May 15, 2026 09:40
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.

2 participants