Complete mail rule reorder IDs - #2304
Conversation
Fetch the current mailbox rule order before reorder requests so partial rule_ids are expanded into the complete list expected by the API. Validate empty, duplicate, and unknown IDs locally before submitting reorder. Co-authored-by: TRAE CLI <noreply@bytedance.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughMail rule reorder support validates requested rule IDs, retrieves all mailbox rules across pages, completes the requested ordering, and routes dry-run and execution flows through the service method. ChangesMail rule reorder
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant serviceMethodRun
participant completeMailRulesReorderRequest
participant fetchAllMailRuleIDs
participant MailRulesAPI
participant ReorderAPI
serviceMethodRun->>completeMailRulesReorderRequest: complete reorder request
completeMailRulesReorderRequest->>fetchAllMailRuleIDs: fetch current rule IDs
fetchAllMailRuleIDs->>MailRulesAPI: list mailbox rule pages
MailRulesAPI-->>fetchAllMailRuleIDs: return paginated rule responses
fetchAllMailRuleIDs-->>completeMailRulesReorderRequest: return all rule IDs
completeMailRulesReorderRequest-->>serviceMethodRun: update completed rule_ids
serviceMethodRun->>ReorderAPI: submit completed reorder request
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 4
🤖 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/mail_rules_reorder_test.go`:
- Around line 103-106: Update all four error-path test sites in
cmd/service/mail_rules_reorder_test.go:103-106, 133-135, 377-383, and 473-475.
Replace message-only checks with typed error assertions covering category and
subtype; assert ValidationError.Param for unknown, empty, and invalid inputs,
verify the wrapped stringList cause at 133-135, and assert the internal
invalid-response category and subtype at 473-475.
In `@cmd/service/mail_rules_reorder.go`:
- Around line 183-190: Update the pagination loop in the mail-rules reorder flow
to track every previously returned non-empty page token and reject duplicates
with errs.NewInternalError(errs.SubtypeInvalidResponse, ...) before issuing
another request. Preserve the existing missing-token validation, and add a
regression test covering has_more=true with a repeated token and confirming the
reorder POST is not executed.
- Around line 105-114: Update the string-list parsing logic around the item
conversion loop to return an error immediately when a trimmed rule ID is empty
instead of skipping it; preserve the existing type validation and non-empty
append behavior. Add a regression test covering a list containing both a valid
rule ID and a blank element, asserting the command reports invalid input.
- Around line 27-43: Update serviceDryRunMailRulesReorder to parse and validate
request.Data locally, preserve the supplied rule_ids such as rule_c and rule_a,
and append only the <remaining_rule_ids_in_current_order> marker without
replacing user IDs. Keep the dry-run plan free of API calls, and update the
related test to assert rule_c, rule_a, then the remaining-rules marker in that
order.
🪄 Autofix
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 Plus
Run ID: dc17f950-6556-44de-a22b-d498db94c999
📒 Files selected for processing (3)
cmd/service/mail_rules_reorder.gocmd/service/mail_rules_reorder_test.gocmd/service/service.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@f17a6716d73ce88ac034cb6a5e003bf9c2584167🧩 Skill updatenpx skills add larksuite/cli#feat/b8c086d -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2304 +/- ##
==========================================
- Coverage 76.53% 76.45% -0.08%
==========================================
Files 1020 1026 +6
Lines 112736 113857 +1121
==========================================
+ Hits 86277 87047 +770
- Misses 19881 20125 +244
- Partials 6578 6685 +107 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Preserve supplied rule IDs in dry-run output, reject blank rule IDs, guard repeated pagination tokens, and assert typed validation metadata in reorder tests. Change-Type: ci-fix Co-authored-by: TRAE CLI <noreply@bytedance.com>
Summary
Tests
Summary by CodeRabbit
New Features
Bug Fixes