Skip to content

feat(apps): validate +file-list --page-size against server (0, 200] range#2007

Open
chenxingyang1019 wants to merge 1 commit into
mainfrom
feat/apps-file-list-page-size
Open

feat(apps): validate +file-list --page-size against server (0, 200] range#2007
chenxingyang1019 wants to merge 1 commit into
mainfrom
feat/apps-file-list-page-size

Conversation

@chenxingyang1019

@chenxingyang1019 chenxingyang1019 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

apps +file-list --page-size now validates against the server's page-size contract before sending the request.

Why

The paas_storage AppFileListForOpenAPI chain rejects page_size > 200 at the inner checkMaxKeys guard:

ErrInvalidRequest: "maxKeys not in range (0, 200]: N"

Previously the CLI forwarded any --page-size straight through, so --page-size 500 produced an opaque server-error round-trip instead of a clear local error.

What changed

  • shortcuts/apps/apps_file_list.go — add a Validate check bounding --page-size to [1, 200], mirroring the existing validateAppsPageSize precedent in the observability commands. Out-of-range values fail fast with a typed validation error (exit 2) and never hit the network. Flag description updated to page size (1..200).
  • shortcuts/apps/apps_file_list_test.go — unit tests for out-of-range (0 / 201 / 500) and boundary (1 / 200) values.
  • skills/lark-apps/references/lark-apps-file.md — document the 1..200 range.

Note on the lower bound

The server tolerates page_size <= 0 by defaulting to 20. The CLI default is already 20 and an explicit < 1 is a user error, so we reject it for a clearer message — consistent with the other list commands. Happy to relax to > 200-only if reviewers prefer strict server-parity.

Testing

  • go build ./... clean; go test ./shortcuts/apps/ green.
  • Ran the online (production) file e2e suite: all file-list cases pass, including 4 new --page-size validation cases (out-of-range → exit 2 no round-trip; 200 boundary → passes).

Summary by CodeRabbit

  • Bug Fixes

    • Added clear validation for file-list page sizes, accepting values from 1 to 200.
    • Invalid values are rejected before a request is sent.
  • Documentation

    • Clarified the default page size and supported range for file-list pagination.

…ange

paas_storage AppFileListForOpenAPI rejects page_size > 200 at the inner
checkMaxKeys guard with ErrInvalidRequest("maxKeys not in range (0, 200]").
Previously the CLI forwarded any --page-size straight to the API, so
--page-size 500 produced an opaque server error round-trip.

Add a client-side Validate check bounding --page-size to [1, 200] (aligned
with the existing validateAppsPageSize precedent in the observability
commands): out-of-range values now fail fast with a typed validation error
and never hit the network. The server tolerates page_size <= 0 by defaulting
to 20, but the CLI default is already 20 and an explicit < 1 is a user error,
so we reject it for a clearer message, consistent with other list commands.

Update the flag description and the lark-apps-file skill reference to
document the 1..200 range, and cover the boundaries in unit tests.
@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The apps +file-list command now validates --page-size values from 1 through 200 before request execution. Tests cover invalid and boundary values, and documentation states the default and allowed range.

Changes

File list page-size validation

Layer / File(s) Summary
Page-size validation and command wiring
shortcuts/apps/apps_file_list.go
Adds client-side validation for --page-size, invokes it during command validation, and updates the flag and endpoint documentation.
Boundary tests and documentation
shortcuts/apps/apps_file_list_test.go, skills/lark-apps/references/lark-apps-file.md
Tests rejected values 0, 201, and 500, accepted boundaries 1 and 200, and documents the default value and valid range.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main change, though the range notation is slightly inconsistent with the implementation.
Description check ✅ Passed The PR description covers motivation, changes, and testing, with only the template headings and Related Issues section formatted differently.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/apps-file-list-page-size

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.

@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: 1

🤖 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 `@shortcuts/apps/apps_file_list_test.go`:
- Around line 101-111: The TestAppsFileList_PageSizeBoundaryOK test only
verifies successful execution and does not confirm the boundary value is
forwarded. Inspect the dry-run payload or built parameters returned by
runAppsShortcut and assert that page_size matches the current ps value for both
"1" and "200", so the test detects regressions in parameter propagation.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee62d3b9-f667-4ec6-a653-68327530e2b5

📥 Commits

Reviewing files that changed from the base of the PR and between 8f6f8eb and 570211d.

📒 Files selected for processing (3)
  • shortcuts/apps/apps_file_list.go
  • shortcuts/apps/apps_file_list_test.go
  • skills/lark-apps/references/lark-apps-file.md

Comment on lines +101 to +111
// TestAppsFileList_PageSizeBoundaryOK 验证边界值 1 与 200 通过校验(dry-run 不报错并把 page_size 下发)。
func TestAppsFileList_PageSizeBoundaryOK(t *testing.T) {
for _, ps := range []string{"1", "200"} {
factory, stdout, _ := newAppsExecuteFactory(t)
if err := runAppsShortcut(t, AppsFileList,
[]string{"+file-list", "--app-id", "app_x", "--page-size", ps, "--dry-run", "--as", "user"},
factory, stdout); err != nil {
t.Fatalf("page-size=%s: dry-run err=%v", ps, err)
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the forwarded page_size value.

Lines 102-108 only verify that dry-run succeeds; the pre-change implementation would also accept 1 and 200. Inspect the dry-run payload or built parameters and assert that page_size equals each boundary value so reverting the implementation makes this test fail.

🤖 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 `@shortcuts/apps/apps_file_list_test.go` around lines 101 - 111, The
TestAppsFileList_PageSizeBoundaryOK test only verifies successful execution and
does not confirm the boundary value is forwarded. Inspect the dry-run payload or
built parameters returned by runAppsShortcut and assert that page_size matches
the current ps value for both "1" and "200", so the test detects regressions in
parameter propagation.

Source: Coding guidelines

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@570211de2ac8f8737ab1cb2fa3232fac35ae002b

🧩 Skill update

npx skills add larksuite/cli#feat/apps-file-list-page-size -y -g

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

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant