feat(apps): friendly error for db commands on an app with no database - #2162
Conversation
Server code 500002759 (a db command run against an app that has not initialized a database yet) previously surfaced with an internal-term message and no actionable next step. withAppsHint now special-cases this code: it rewrites the message to a user-facing "this app does not have a database yet" and forces a cloud-development recovery hint (session-list/create -> chat -> poll session-get -> retry). Because every apps db command funnels through withAppsHint and this code is db-endpoint-specific, the whole db command family is covered without per-command changes.
|
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)
📝 WalkthroughWalkthroughThe change adds constants and special handling for Spark error code ChangesSpark no-database error handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 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: 2
🤖 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/common_test.go`:
- Around line 61-78: Extend the “no-database code rewrites message and forces
cloud-dev hint” test to assert that p.Category and p.Subtype retain the input
error’s classification, and assert out == in to verify withAppsHint returns the
original error instance. Keep the existing message, hint, and code assertions
unchanged.
In `@shortcuts/apps/common.go`:
- Line 43: Update the final instruction in appNoDatabaseHint to tell the user to
retry the original database command rather than hard-coding +db-table-list.
Preserve the existing session creation, message submission, and polling
instructions so withAppsHint can recover whichever database command failed.
🪄 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 Plus
Run ID: 743891d8-f3d1-4769-814d-fe8865198d75
📒 Files selected for processing (2)
shortcuts/apps/common.goshortcuts/apps/common_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@048b2f3d8b5ab0ee9addb716aa9b7c126658375a🧩 Skill updatenpx skills add larksuite/cli#feat/db-no-database-hint -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2162 +/- ##
=======================================
Coverage 75.69% 75.69%
=======================================
Files 942 942
Lines 100079 100083 +4
=======================================
+ Hits 75750 75754 +4
Misses 18537 18537
Partials 5792 5792 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Address review feedback on the no-database (500002759) recovery hint: - The hint's final step named `+db-table-list` specifically, which would redirect the operation when a different db command triggered it. Replace it with "retry the original db command" so the recovery flow always resumes whatever the caller ran. - Strengthen the unit test to assert the helper returns the same error value (cause chain preserved) and leaves Category/Subtype/Code intact, not just the rewritten Message/Hint.
What
Server code
500002759— a db command run against an app that has not initialized a database yet — previously surfaced with an internal-term message and no actionable next step.withAppsHintnow special-cases this code:this app does not have a database yet(drops internal workspace / db-branch terms)+session-list/+session-create→+chat(send the database requirement) → poll+session-getuntillatest_turn.status=completed→ retry+db-table-listThe override is unconditional for this code (it also replaces any upstream hint), since the recovery flow is more actionable than any generic hint.
Why this placement
500002759is produced only by db endpoints, and every apps db command funnels throughwithAppsHint, so the whole db command family (+db-table-list/-table-get/-execute/-data-import|export/-changelog-list/-audit-*/-quota-get/-recovery-*/-env-*) is covered without per-command changes. Kept entirely in the apps shortcut layer — nointernal/classification change.Verification
Unit tests in
common_test.gocover: code match rewrites message + forces hint; a preexisting upstream hint is overridden.Live prod check against a no-database app (
app_4k4a5fbdahm83):+db-table-list+db-table-get+db-execute --yesgo build ./...andgo test ./shortcuts/apps/pass.Summary by CodeRabbit