bug: /refractor status page overflow shows "no data" instead of clamping to last page #141
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#141
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
When a user passes a page number beyond the total pages (e.g.
/refractor status page:999), the bot returns "No refractor data found for your team." instead of clamping to the last valid page.Root Cause
In
cogs/refractor.py, the status command sendslimitandoffsetdirectly to the API (line 338-339). When page=999, the offset becomes 9980, the API returns{"count": 13, "items": []}, and the cog falls through to the "no data" message at line 380 without checking thatcount > 0.The
paginate()helper function (line 194) handles clamping correctly, but it's not used here — pagination is done server-side.Expected Behavior
/refractor status page:999should clamp to the last page and display those cards (same as/refractor status page:0correctly clamps to page 1).Suggested Fix
After the API call, when
itemsis empty buttotal_count > 0, recalculate the page toceil(total_count / PAGE_SIZE)and re-fetch with the corrected offset. Or pre-clamp on the first request by fetching count first.Steps to Reproduce
/refractor status page:999Test Reference
REF-22 in
tests/refractor-integration-test-plan.mdPR #142 opened: #142
Fix adds a re-fetch guard after the initial API call: when
itemsis empty buttotal_count > 0, the page is clamped to the last valid page and a second request is made with the corrected offset. Ruff passed clean.