Skip to content

Conversation

Copy link

Copilot AI commented Nov 24, 2025

The API endpoint /api/holes/{hole_id}/floors?size=0&offset=0 was returning only 30 floors instead of all floors. The validation framework applies a default value of 30 when size=0 is passed, preventing the special case from being detected.

Changes

  • apis/floor/apis.go: Check raw query parameters before validation to detect explicit size=0&offset=0 and pass nil to MakeQuerySet for unlimited results
  • tests/floor_test.go: Add test case verifying all 50 test floors are returned
  • .gitignore: Add treehole_next binary

Example

// Before: validation converts size=0 to size=30
var query ListModel
err = common.ValidateQuery(c, &query)  // query.Size now = 30

// After: check raw params first
rawSize := c.Query("size")
rawOffset := c.Query("offset")
if rawSize == "0" && rawOffset == "0" {
    querySet, err = floors.MakeQuerySet(&holeID, nil, nil, c)  // No limit
}

This matches the existing behavior in ListFloorsOld for backward compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] 请求全部楼层时,仅返回前 30 层</issue_title>
<issue_description>如题,请求为:

url:https://forum.fduhole.com/api/holes/493044/floors?offset=0&size=0
method:GET
requestTime:2025.08.07-15:50:51:18
responseTime:2025.08.07-15:50:51:63
duration:45ms
body:null
params:{
  "offset": 0,
  "size": 0
}
header:{<略>, cookie: null}

返回为:

[
  {
    "id": 4533213,
    "time_created": "2025-08-05T14:24:43.6+08:00",
    "time_updated": "2025-08-07T10:10:02.256+08:00",
<略>
  },
]

返回中的数组只有 30 个项目。

下游 issue:DanXi-Dev/DanXi#565</issue_description>

<agent_instructions>Keep modifications minimal.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 6 commits November 24, 2025 06:22
- Added check for raw query parameters before validation applies defaults
- When both size=0 and offset=0, return all floors instead of limiting to 30
- Added test case to verify the fix
- Added treehole_next binary to .gitignore

Co-authored-by: KYLN24 <[email protected]>
Copilot AI changed the title [WIP] Fix issue with floor request limiting response to 30 items Fix size=0 query parameter to return all floors instead of default 30 Nov 24, 2025
Copilot AI requested a review from KYLN24 November 24, 2025 06:33
@KYLN24 KYLN24 requested review from Copilot and ppolariss and removed request for KYLN24 November 24, 2025 09:48
Copy link

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

This PR fixes a bug where the API endpoint /api/holes/{hole_id}/floors?size=0&offset=0 was incorrectly returning only 30 floors instead of all floors. The issue occurs because the ListModel schema has a default:"30" tag that causes the validation framework to replace size=0 with the default value of 30, preventing the special case logic from detecting the request for all floors.

Key Changes:

  • Added raw query parameter checking before validation to detect explicit size=0&offset=0 requests
  • Updated ListFloorsInAHole to pass nil for both offset and size to MakeQuerySet when the special case is detected, returning all floors without limit
  • Added test case to verify all 50 test floors are returned with size=0&offset=0 parameters

Reviewed changes

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

File Description
.gitignore Adds treehole_next binary to gitignore
tests/floor_test.go Adds test case verifying size=0&offset=0 returns all 50 floors in the test hole
apis/floor/apis.go Implements raw query parameter check before validation to detect size=0&offset=0 and bypass pagination, matching ListFloorsOld behavior for backward compatibility

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

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.

[BUG] 请求全部楼层时,仅返回前 30 层

2 participants