Skip to content

feat(apps): friendly error for db commands on an app with no database - #2162

Merged
chenxingyang1019 merged 3 commits into
mainfrom
feat/db-no-database-hint
Aug 4, 2026
Merged

feat(apps): friendly error for db commands on an app with no database#2162
chenxingyang1019 merged 3 commits into
mainfrom
feat/db-no-database-hint

Conversation

@chenxingyang1019

@chenxingyang1019 chenxingyang1019 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

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.

withAppsHint now special-cases this code:

  • message rewritten to a user-facing this app does not have a database yet (drops internal workspace / db-branch terms)
  • hint forced to a cloud-development recovery flow: +session-list/+session-create+chat (send the database requirement) → poll +session-get until latest_turn.status=completed → retry +db-table-list

The 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

500002759 is produced only by db endpoints, and every apps db command funnels through withAppsHint, 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 — no internal/ classification change.

Verification

Unit tests in common_test.go cover: code match rewrites message + forces hint; a preexisting upstream hint is overridden.

Live prod check against a no-database app (app_4k4a5fbdahm83):

command result
+db-table-list message rewritten + recovery hint injected
+db-table-get message rewritten
+db-execute --yes message rewritten (after reaching server)

go build ./... and go test ./shortcuts/apps/ pass.

Summary by CodeRabbit

  • Bug Fixes
    • Improved guidance for a specific database error with a clearer message and cloud-development recovery instructions.
    • Preserved existing handling and error details for other errors.

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.
@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 57111fb9-1671-4fcf-ac61-15ff710bec71

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0c4f1 and 048b2f3.

📒 Files selected for processing (2)
  • shortcuts/apps/common.go
  • shortcuts/apps/common_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/apps/common_test.go
  • shortcuts/apps/common.go

📝 Walkthrough

Walkthrough

The change adds constants and special handling for Spark error code 500002759. The handler standardizes its message and cloud-development recovery hint. Tests verify code preservation and precedence over existing hints.

Changes

Spark no-database error handling

Layer / File(s) Summary
Standardized no-database error flow
shortcuts/apps/common.go, shortcuts/apps/common_test.go
The handler rewrites Spark error 500002759 with a standardized message and cloud-development recovery hint. Tests verify in-place mutation, preserved error fields, and hint precedence.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the friendly database error added for apps without an initialized database.
Description check ✅ Passed The description explains the motivation, implementation, coverage, recovery flow, and verification results, although it uses different section headings than the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/db-no-database-hint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ba10438 and 4c0c4f1.

📒 Files selected for processing (2)
  • shortcuts/apps/common.go
  • shortcuts/apps/common_test.go

Comment thread shortcuts/apps/common_test.go
Comment thread shortcuts/apps/common.go Outdated
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@048b2f3d8b5ab0ee9addb716aa9b7c126658375a

🧩 Skill update

npx skills add larksuite/cli#feat/db-no-database-hint -y -g

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.69%. Comparing base (0f29e03) to head (048b2f3).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@chenxingyang1019
chenxingyang1019 merged commit ec882dd into main Aug 4, 2026
41 of 54 checks passed
@chenxingyang1019
chenxingyang1019 deleted the feat/db-no-database-hint branch August 4, 2026 03:53
@liangshuo-1 liangshuo-1 mentioned this pull request Aug 4, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants