fix: rule-engine pagination#40
Merged
Merged
Conversation
There was a problem hiding this comment.
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/offsetuntil the second pagination request, and break early if the first response has nototal_count(legacy unpaginated endpoint), synthesizingtotal_countfrom the items length when needed. - Make
total_countoptional inpaginateRespProcesor.Processand improve error message on non-200 responses. - Update existing fixtures (sites, rule-engine rules) to drop the first-page
limit/offsetquery, 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.
a4141f6 to
0fb93e1
Compare
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.
No description provided.