refactor(apps): migrate errors to typed taxonomy#1288
Conversation
📝 WalkthroughWalkthroughThis PR migrates the ChangesApps Domain Typed Error Migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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@deb12ebc1a5363b0b9515dfb9f442e2d9acf73b1🧩 Skill updatenpx skills add larksuite/cli#feat/errs-migrate-apps -y -g |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1288 +/- ##
=======================================
Coverage 70.33% 70.33%
=======================================
Files 672 674 +2
Lines 65322 65357 +35
=======================================
+ Hits 45941 45966 +25
- Misses 15728 15733 +5
- Partials 3653 3658 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/apps/html_publish_client_test.go (1)
21-31:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd config-dir isolation in the test runtime helper.
newAppsClientRuntimeusescmdutil.TestFactorybut does not isolate config state. This can leak state across tests when config-backed paths are touched.💡 Suggested fix
func newAppsClientRuntime(t *testing.T) (*common.RuntimeContext, *httpmock.Registry) { t.Helper() + t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) cfg := &core.CliConfig{ AppID: "test-app-" + strings.ToLower(t.Name()), AppSecret: "test-secret", Brand: core.BrandFeishu, UserOpenId: "ou_test", }As per coding guidelines:
**/*_test.gomustUse t.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/apps/html_publish_client_test.go` around lines 21 - 31, The test helper newAppsClientRuntime should isolate config state: before calling cmdutil.TestFactory set the environment var LARKSUITE_CLI_CONFIG_DIR to a temp dir via t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()), so tests don't share config-backed paths; update newAppsClientRuntime to call t.Setenv(...) as the first action in the function (reference newAppsClientRuntime and the call site cmdutil.TestFactory).
🤖 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.
Outside diff comments:
In `@shortcuts/apps/html_publish_client_test.go`:
- Around line 21-31: The test helper newAppsClientRuntime should isolate config
state: before calling cmdutil.TestFactory set the environment var
LARKSUITE_CLI_CONFIG_DIR to a temp dir via t.Setenv("LARKSUITE_CLI_CONFIG_DIR",
t.TempDir()), so tests don't share config-backed paths; update
newAppsClientRuntime to call t.Setenv(...) as the first action in the function
(reference newAppsClientRuntime and the call site cmdutil.TestFactory).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cad262b6-f9b7-409c-93ee-75177089ac7c
📒 Files selected for processing (17)
.golangci.ymlinternal/errclass/codemeta_apps.golint/errscontract/rule_no_legacy_common_helper_call.golint/errscontract/rule_no_legacy_envelope_literal.goshortcuts/apps/apps_access_scope_get.goshortcuts/apps/apps_access_scope_set.goshortcuts/apps/apps_create.goshortcuts/apps/apps_create_test.goshortcuts/apps/apps_errors.goshortcuts/apps/apps_html_publish.goshortcuts/apps/apps_html_publish_test.goshortcuts/apps/apps_list.goshortcuts/apps/apps_update.goshortcuts/apps/html_publish_client.goshortcuts/apps/html_publish_client_test.goshortcuts/apps/html_publish_tarball.goshortcuts/apps/walk_html_publish_candidates.go
Summary
Migrate the apps shortcut domain to the typed
errs.*error taxonomy so validation, file handling, SDK/API failures, and Miaoda HTML publish errors emit structured typed envelopes.Changes
errs.*builders and typed helper functions.CallAPItoCallAPITyped; keep multipart HTML publish onDoAPIwhile classifying responses throughClassifyAPIResponse.output.ExitErrordetails.Test Plan
go test ./shortcuts/apps ./internal/errclassgo test ./errscontractfrom thelintmodulemake unit-testlark-cli apps <command>flow works as expectedlark-cli apps +create --name Demo --app-type HTML --dry-run --as userlark-cli apps +html-publish --app-id app_x --path <site> --dry-run --as usergo vet ./...gofmt -l .git diff --checkgo mod tidyproduced nogo.mod/go.sumdiffgo run -C lint . ..golangci-lint v2.1.6 run --new-from-rev=origin/mainRelated Issues
Summary by CodeRabbit
Refactor
Tests
Chores