feat(drive): harden inspect shortcut failures#1323
Conversation
📝 WalkthroughWalkthroughThis PR upgrades Drive inspect and Drive meta operations with typed error handling and rate-limit resilience. FetchDriveMeta now returns typed problem errors; DriveInspect adds centralized URL/type validation, configurable retry with exponential backoff, and error annotation with stage labels for better diagnostics. ChangesDrive Inspect Resilience and Typed Error Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@b54abe817cf5da7df4cdd70b5a1bc4471189a62a🧩 Skill updatenpx skills add larksuite/cli#codex/inspect-cli-precheck -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1323 +/- ##
==========================================
- Coverage 71.42% 71.42% -0.01%
==========================================
Files 688 688
Lines 65313 65384 +71
==========================================
+ Hits 46653 46703 +50
- Misses 15021 15035 +14
- Partials 3639 3646 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
shortcuts/drive/drive_inspect_test.go (2)
89-115: ⚡ Quick winUse the standard test factory helper in these new validate tests.
These new unit tests build runtime context directly via
common.TestNewRuntimeContext(...)instead of the repository-standard test factory helper.As per coding guidelines,
**/*_test.go: "Usecmdutil.TestFactory(t, config)for test factories in unit tests".🤖 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/drive/drive_inspect_test.go` around lines 89 - 115, Replace direct use of common.TestNewRuntimeContext in TestDriveInspectValidate_URLTypeConflict and TestDriveInspectValidate_BareTokenWithPathFragment with the repository-standard test factory helper (cmdutil.TestFactory or TestFactory(t, config)) so the tests construct the runtime via the shared factory; locate the two tests and change the runtime creation before calling DriveInspect.Validate to use the standard TestFactory helper with the same config values.Source: Coding guidelines
583-586: ⚡ Quick winIsolate config state in this TestFactory-based test.
Add
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())before factory/runtime setup to keep config state isolated per test.As per coding guidelines,
**/*_test.go: "Uset.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())to isolate config state in tests".🤖 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/drive/drive_inspect_test.go` around lines 583 - 586, In TestDriveInspectExecute_RetriesRateLimitOnWikiResolve insert a call to t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) before creating the test factory/runtime (before calling cmdutil.TestFactory or driveTestConfig) so the TestFactory-based setup uses an isolated per-test config directory; this ensures config state is isolated for this test.Source: Coding guidelines
🤖 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/drive/drive_inspect_test.go`:
- Around line 578-579: The test currently uses strings.Contains to check
p.Message but the contract expects a prefix; update the assertion in the test to
use strings.HasPrefix instead of strings.Contains (i.e., replace the condition
with !strings.HasPrefix(p.Message, "query document metadata failed")) and keep
the t.Fatalf message so the test fails if the message does not start with that
prefix (reference p.Message and the failing t.Fatalf call).
---
Nitpick comments:
In `@shortcuts/drive/drive_inspect_test.go`:
- Around line 89-115: Replace direct use of common.TestNewRuntimeContext in
TestDriveInspectValidate_URLTypeConflict and
TestDriveInspectValidate_BareTokenWithPathFragment with the repository-standard
test factory helper (cmdutil.TestFactory or TestFactory(t, config)) so the tests
construct the runtime via the shared factory; locate the two tests and change
the runtime creation before calling DriveInspect.Validate to use the standard
TestFactory helper with the same config values.
- Around line 583-586: In TestDriveInspectExecute_RetriesRateLimitOnWikiResolve
insert a call to t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) before
creating the test factory/runtime (before calling cmdutil.TestFactory or
driveTestConfig) so the TestFactory-based setup uses an isolated per-test config
directory; this ensures config state is isolated for this test.
🪄 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: bfcb63a8-71b0-4caa-8d07-aa8ac572b523
📒 Files selected for processing (4)
shortcuts/common/drive_meta.goshortcuts/common/drive_meta_test.goshortcuts/drive/drive_inspect.goshortcuts/drive/drive_inspect_test.go
Summary
Testing
Summary by CodeRabbit
New Features
Improvements