feat: add client-side page_size validation for service commands#1222
feat: add client-side page_size validation for service commands#1222xukuncx wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds selective query parameter range validation for service requests. A static allowlist maps service schema paths to specific parameter names eligible for validation. When building service requests, ChangesQuery Parameter Range Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/service/service.go (1)
437-444: 💤 Low value
validateQueryParamRange(name, value, nil, …)is always a no-op here.This second loop only handles params not already mapped to a declared query param, so
paramSpecis alwaysniland the helper returns immediately at Line 549-551. The call neither validates nor documents a future constraint source. Consider dropping it to avoid implying validation that can never run.♻️ Optional simplification
for name, value := range params { if _, ok := queryParams[name]; !ok { - if err := validateQueryParamRange(name, value, nil, schemaPath); err != nil { - return client.RawApiRequest{}, nil, err - } queryParams[name] = value } }🤖 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 `@cmd/service/service.go` around lines 437 - 444, The second loop over params is calling validateQueryParamRange(name, value, nil, schemaPath) but since this loop only handles names not in queryParams the helper always receives paramSpec == nil and returns immediately; remove the no-op call to validateQueryParamRange from that loop and just set queryParams[name] = value (or, if you intended to validate against a fallback/global constraint, replace the nil paramSpec with the appropriate spec lookup before calling validateQueryParamRange). Ensure references to queryParams, params, validateQueryParamRange, and schemaPath are updated accordingly.
🤖 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.
Nitpick comments:
In `@cmd/service/service.go`:
- Around line 437-444: The second loop over params is calling
validateQueryParamRange(name, value, nil, schemaPath) but since this loop only
handles names not in queryParams the helper always receives paramSpec == nil and
returns immediately; remove the no-op call to validateQueryParamRange from that
loop and just set queryParams[name] = value (or, if you intended to validate
against a fallback/global constraint, replace the nil paramSpec with the
appropriate spec lookup before calling validateQueryParamRange). Ensure
references to queryParams, params, validateQueryParamRange, and schemaPath are
updated accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c6783135-69c7-4b7f-a92b-1bd694beb5fd
📒 Files selected for processing (2)
cmd/service/service.gocmd/service/service_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@734f73d69a86a31dac684dd85c3c35ce46b29c0b🧩 Skill updatenpx skills add xukuncx/cli#feat/1694214 -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1222 +/- ##
==========================================
- Coverage 69.90% 69.67% -0.24%
==========================================
Files 645 667 +22
Lines 60235 64465 +4230
==========================================
+ Hits 42110 44914 +2804
- Misses 14823 15943 +1120
- Partials 3302 3608 +306 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🤖 AI Review | [P3 可维护性] PR 描述残留恢复运行过程信息 PR 描述包含 修复建议: 将描述改为自包含的 如有疑问或认为判断不准确,欢迎直接回复讨论。 |
|
🤖 AI Review | CR 汇总 | 可合入(2 个建议项) 增量审查:基于之前 1 条 CodeRabbit 审查意见,本次新增 1 条评论。
其中 |
|
🤖 AI Review | CR 汇总 | 可合入(无新增代码问题) 增量审查:基于之前的 CodeRabbit 评论和 2 条 AI Review 评论,本次针对当前 head
验证: 附注:GitHub 当前显示 |
There was a problem hiding this comment.
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 `@cmd/service/param_validation.go`:
- Around line 57-72: The min/max parsing currently swallows parse errors and
silently skips the bound check; update the blocks that call strconv.ParseInt on
minStr and maxStr (the code surrounding registry.GetStrFromMap, minStr/maxStr,
and strconv.ParseInt) to detect a non-nil err and return a validation error
instead of ignoring it—use errs.NewValidationError (same pattern as the existing
errors) to report a malformed bound for the parameter name and include a helpful
hint (use WithHint and WithParam) referencing schemaPath so callers know to fix
the paramSpec.
🪄 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: 30589444-7cda-4c5d-9c18-80f72bd2df4f
📒 Files selected for processing (3)
cmd/service/param_validation.gocmd/service/param_validation_test.gocmd/service/service.go
💤 Files with no reviewable changes (1)
- cmd/service/service.go
209b88e to
335083c
Compare
Generated by the harness-coding skill (recovery run — original attempt crashed before MR open).
Commits on branch (ahead of main)
This resume run
This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.
Summary by CodeRabbit
Bug Fixes
Tests