Skip to content

fix(apps): make db --environment optional, auto-select branch server-side#1735

Open
chenxingyang1019 wants to merge 1 commit into
mainfrom
fix/apps-db-env-optional
Open

fix(apps): make db --environment optional, auto-select branch server-side#1735
chenxingyang1019 wants to merge 1 commit into
mainfrom
fix/apps-db-env-optional

Conversation

@chenxingyang1019

@chenxingyang1019 chenxingyang1019 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

All db shortcuts defaulted --environment to "dev", which forced single-env apps (whose DB lives on the online branch, with no dev branch) to fail with "Invalid DB Branch: dev" unless the user explicitly passed --environment online.

Change the default to empty: when --environment is omitted the CLI sends no env, letting the server pick the branch by the app's multi-env state (multi-env → dev, single-env → online), matching miaoda-cli's behavior of not carrying dbBranch when unset. Explicit --environment dev|online is unchanged; explicit dev on a single-env app still errors as expected.

Changes

  • 10 db shortcuts: dbEnvFlags default "dev" → "" (+db-execute, +db-table-list, +db-table-get, +db-quota-get, +db-data-export, +db-data-import, +db-changelog-list, +db-audit-list/-set/-status)
  • dry-run e2e assertions updated: default env is now unset, not "dev"
  • skill docs (lark-apps-db, lark-apps-db-execute) describe the auto-select

Test Plan

  • Unit tests pass (go test ./shortcuts/apps/ ./tests/cli_e2e/apps/ all green)
  • Manual local verification confirms the lark-cli apps +db-* flow works as expected
    • BOE cli_e2e.sh: 91 passed, 0 failed (incl. new "no --environment" dry-run + live cases)
    • Single-env app app_179b0qed55k (BOE): no env / onlineok=true; explicit dev500002511 as expected

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes
    • Database commands now auto-select the target environment when --env / --environment is left unset, instead of defaulting to dev.
    • Single-environment apps use online by default, while multi-environment apps use dev.
  • Documentation
    • Updated command help text and reference docs to reflect the new default/auto-selection behavior.
  • Tests
    • Refreshed CLI end-to-end coverage to verify dry-run requests send an empty env when the flag is omitted.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 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

Run ID: be3c140e-b2ef-44cf-92b5-b297de7029c7

📥 Commits

Reviewing files that changed from the base of the PR and between 9b1145c and d752ab9.

📒 Files selected for processing (14)
  • shortcuts/apps/apps_db_audit_list.go
  • shortcuts/apps/apps_db_audit_set.go
  • shortcuts/apps/apps_db_audit_status.go
  • shortcuts/apps/apps_db_changelog_list.go
  • shortcuts/apps/apps_db_data_export.go
  • shortcuts/apps/apps_db_data_import.go
  • shortcuts/apps/apps_db_execute.go
  • shortcuts/apps/apps_db_quota_get.go
  • shortcuts/apps/apps_db_table_get.go
  • shortcuts/apps/apps_db_table_list.go
  • skills/lark-apps/references/lark-apps-db-execute.md
  • skills/lark-apps/references/lark-apps-db.md
  • tests/cli_e2e/apps/apps_db_execute_dryrun_test.go
  • tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-apps/references/lark-apps-db-execute.md
🚧 Files skipped from review as they are similar to previous changes (13)
  • tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go
  • shortcuts/apps/apps_db_execute.go
  • shortcuts/apps/apps_db_table_get.go
  • shortcuts/apps/apps_db_audit_list.go
  • shortcuts/apps/apps_db_audit_status.go
  • shortcuts/apps/apps_db_changelog_list.go
  • shortcuts/apps/apps_db_quota_get.go
  • shortcuts/apps/apps_db_audit_set.go
  • shortcuts/apps/apps_db_data_import.go
  • tests/cli_e2e/apps/apps_db_execute_dryrun_test.go
  • shortcuts/apps/apps_db_data_export.go
  • shortcuts/apps/apps_db_table_list.go
  • skills/lark-apps/references/lark-apps-db.md

📝 Walkthrough

Walkthrough

Multiple apps db shortcut commands change their dbEnvFlags default from "dev" to "", shifting the --env/--environment flag behavior from a fixed default to server-side auto-selection (multi-env apps → dev, single-env apps → online). Documentation and dry-run tests are updated accordingly.

Changes

DB environment auto-selection

Layer / File(s) Summary
Update dbEnvFlags default across db shortcut commands
shortcuts/apps/apps_db_audit_list.go, shortcuts/apps/apps_db_audit_set.go, shortcuts/apps/apps_db_audit_status.go, shortcuts/apps/apps_db_changelog_list.go, shortcuts/apps/apps_db_data_export.go, shortcuts/apps/apps_db_data_import.go, shortcuts/apps/apps_db_execute.go, shortcuts/apps/apps_db_quota_get.go, shortcuts/apps/apps_db_table_get.go, shortcuts/apps/apps_db_table_list.go
dbEnvFlags default argument changes from "dev" to "" across ten commands, with help text updated to describe auto-selection when the flag is left unset.
Update documentation for auto-select behavior
skills/lark-apps/references/lark-apps-db-execute.md, skills/lark-apps/references/lark-apps-db.md
Reference docs are rewritten to describe environment auto-selection rules instead of a fixed dev default.
Update dry-run test expectations for empty env
tests/cli_e2e/apps/apps_db_execute_dryrun_test.go, tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go
Dry-run test subtest names and api.0.params.env assertions are updated to expect an empty string instead of "dev" when --environment is unset.

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

Suggested labels: feature

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: making db --environment optional with server-side auto-selection.
Description check ✅ Passed The description follows the template and includes a summary, changes, test plan, and related issues.
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 fix/apps-db-env-optional

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.

…side

All db shortcuts defaulted --environment to "dev", which forced single-env
apps (whose DB lives on the online branch, with no dev branch) to fail with
"Invalid DB Branch: dev" unless the user explicitly passed --environment
online.

Change the default to empty: when --environment is omitted the CLI sends no
env, letting the server pick the branch by the app's multi-env state
(multi-env → dev, single-env → online), matching miaoda-cli's behavior of
not carrying dbBranch when unset. Explicit --environment dev|online is
unchanged; explicit dev on a single-env app still errors as expected.

- 10 db shortcuts: dbEnvFlags default "dev" → "" (+db-execute, +db-table-list,
  +db-table-get, +db-quota-get, +db-data-export, +db-data-import,
  +db-changelog-list, +db-audit-list/-set/-status)
- dry-run e2e assertions updated: default env is now unset, not "dev"
- skill docs (lark-apps-db, lark-apps-db-execute) describe the auto-select
@chenxingyang1019 chenxingyang1019 force-pushed the fix/apps-db-env-optional branch from 9b1145c to d752ab9 Compare July 3, 2026 07:45
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/apps-db-env-optional -y -g

@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: 1

🤖 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/apps_db_audit_list.go`:
- Line 43: The DB audit/list command setup uses an empty default env via
dbEnvFlags, but the tests do not cover the no-`--environment` path. Update the
relevant tests in apps_db_audit_test and apps_db_changelog_list_test to add a
dry-run assertion for the default empty env case, alongside the existing env=dev
coverage, so the command behavior is verified when env is unset.
🪄 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: a345fb27-f13b-48c8-88da-31173d1768ce

📥 Commits

Reviewing files that changed from the base of the PR and between 73be1d0 and 9b1145c.

📒 Files selected for processing (14)
  • shortcuts/apps/apps_db_audit_list.go
  • shortcuts/apps/apps_db_audit_set.go
  • shortcuts/apps/apps_db_audit_status.go
  • shortcuts/apps/apps_db_changelog_list.go
  • shortcuts/apps/apps_db_data_export.go
  • shortcuts/apps/apps_db_data_import.go
  • shortcuts/apps/apps_db_execute.go
  • shortcuts/apps/apps_db_quota_get.go
  • shortcuts/apps/apps_db_table_get.go
  • shortcuts/apps/apps_db_table_list.go
  • skills/lark-apps/references/lark-apps-db-execute.md
  • skills/lark-apps/references/lark-apps-db.md
  • tests/cli_e2e/apps/apps_db_execute_dryrun_test.go
  • tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go

Comment thread shortcuts/apps/apps_db_audit_list.go
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.40%. Comparing base (73be1d0) to head (d752ab9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1735   +/-   ##
=======================================
  Coverage   74.40%   74.40%           
=======================================
  Files         853      853           
  Lines       88311    88311           
=======================================
  Hits        65704    65704           
  Misses      17544    17544           
  Partials     5063     5063           

☔ 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.

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.

1 participant