Skip to content

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

Open
chenxingyang1019 wants to merge 2 commits into
mainfrom
fix/apps-db-env-optional
Open

fix(apps): make db --environment optional, auto-select branch server-side#1735
chenxingyang1019 wants to merge 2 commits 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.
    • The env parameter is only sent when an explicit environment value is provided; otherwise it’s omitted so the server can choose (single-env → online, multi-env → dev).
  • Documentation
    • Updated command help text and reference docs to match the new unset/auto-selection behavior and the removal of legacy --env.
  • Tests
    • Updated CLI end-to-end dry-run assertions to confirm env is omitted when the flag is not provided.

@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

📝 Walkthrough

Walkthrough

DB shortcut commands now leave --env/--environment unset by default, only add env to requests when a value is present, and update documentation and dry-run tests to expect omitted environment parameters.

Changes

DB environment auto-selection

Layer / File(s) Summary
Add env parameter helper
shortcuts/apps/db_common.go
A shared helper conditionally writes the env query parameter based on the resolved DB environment.
Unset env by default
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
DB shortcut flag wiring changes from a hardcoded dev default to an unset default with updated auto-selection help text.
Build requests without empty env
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
Audit, changelog, export, import, execute, quota, and table requests now use the shared helper or conditional logic so env is only included when non-empty.
Update db environment docs
skills/lark-apps/references/lark-apps-db-execute.md, skills/lark-apps/references/lark-apps-db.md
Reference documentation now describes unset environment auto-selection and the related explicit environment behavior.
Update dry-run assertions
tests/cli_e2e/apps/apps_db_execute_dryrun_test.go, tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go
Dry-run tests now expect env to be omitted when environment is not provided.

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

Possibly related PRs

  • larksuite/cli#1596 — Introduces the DB shortcut codepaths whose env-flag and request-parameter wiring are updated here.

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 required template with Summary, Changes, Test Plan, and Related Issues sections filled in.
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@f984e16d3ae3e557dd2f02722ffb2d89b931c8d8

🧩 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

❌ Patch coverage is 77.08333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.42%. Comparing base (73be1d0) to head (f984e16).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/apps/apps_db_audit_list.go 55.55% 2 Missing and 2 partials ⚠️
shortcuts/apps/apps_db_data_export.go 75.00% 2 Missing and 2 partials ⚠️
shortcuts/apps/apps_db_data_import.go 60.00% 1 Missing and 1 partial ⚠️
shortcuts/apps/apps_db_quota_get.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1735      +/-   ##
==========================================
+ Coverage   74.40%   74.42%   +0.02%     
==========================================
  Files         853      854       +1     
  Lines       88311    88492     +181     
==========================================
+ Hits        65704    65857     +153     
- Misses      17544    17560      +16     
- Partials     5063     5075      +12     

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

…kill doc

Address PR #1735 review:
- omit-empty: when --environment is unset, drop the env query key entirely
  instead of sending env="" — matches the family's omit-empty convention
  (cf. page_token) and miaoda-cli's "no dbBranch when unset". Add dbEnvParams
  helper; apply across all db shortcuts (execute, table-list/-get, quota-get,
  changelog-list, audit-list/-set/-status, data-export/-import) plus the
  export/import query params, queryExportTotal and audit-list table/status probes.
- e2e dry-run assertions pin env is omitted via .Exists() (was Equal "").
- skill doc (lark-apps-db): rewrite the --environment guidance from an agent's
  decision POV — read vs write, single-env writes hit online prod, explicit dev
  on single-env as a probe; drop redundant/changelog phrasing.

@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

♻️ Duplicate comments (2)
shortcuts/apps/apps_db_changelog_list.go (1)

79-82: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Confirm dry-run test coverage for the unset-env default.

Prior review noted shortcuts/apps/apps_db_changelog_list_test.go only exercises env=dev, not the no---environment path that this refactor now defaults to.

🤖 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/apps_db_changelog_list.go` around lines 79 - 82, The changelog
parameter builder in buildChangelogParams now defaults unset environment
handling, but the tests only cover the env=dev path. Add or update coverage in
shortcuts/apps/apps_db_changelog_list_test.go for the no--environment case to
verify the dry-run/default behavior matches the new dbEnvParams logic and the
fallback environment is applied correctly.

Source: Coding guidelines

shortcuts/apps/apps_db_audit_list.go (1)

217-231: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Confirm dry-run test coverage for the unset-env default.

A prior review noted shortcuts/apps/apps_db_audit_test.go doesn't assert env at all for the no---environment path, and the same coding guideline ("Every behavior change needs a test alongside the change") applies here since buildAuditListParams/fetchExistingTables/fetchAuditEnabledTables now build params without env by default.

🤖 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/apps_db_audit_list.go` around lines 217 - 231, Confirm the
no-`--environment` dry-run path is covered by a test, since
`buildAuditListParams`, `fetchExistingTables`, and `fetchAuditEnabledTables` now
omit `env` by default. Update `shortcuts/apps/apps_db_audit_test.go` to assert
the generated params for the unset-environment case, including that `env` is
absent when the flag is not provided. Keep the test aligned with the existing
dry-run coverage and verify the behavior through the same audit-list parameter
builder flow.

Source: Coding guidelines

🧹 Nitpick comments (1)
shortcuts/apps/db_common.go (1)

37-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Comment language inconsistency.

Logic is correct, but the doc comment (lines 37-39) is written in Chinese while the rest of the codebase (e.g., copyright headers, other shortcut files) uses English. Consider translating for consistency and to keep the codebase accessible to all contributors.

✏️ Suggested English comment
-// dbEnvParams 把 env 并入 params:仅当显式指定了环境(非空)才带 env 键;未指定(空)时
-// 省略该键,由服务端按应用多环境状态自动选分支(多环境→dev,单环境→online)。与家族对
-// 空可选参数的 omit-empty 约定一致——不发空串,wire 上真正不带 env。原样返回同一个 map 便于链式。
+// dbEnvParams merges env into params: only sets the "env" key when an
+// environment is explicitly specified (non-empty). When unset, the key is
+// omitted so the server can auto-select the branch based on the app's
+// multi-environment state (multi-env -> dev, single-env -> online). This
+// follows the family's omit-empty convention for optional params—no empty
+// string is sent on the wire. Returns the same map for chaining.
 func dbEnvParams(rctx *common.RuntimeContext, params map[string]interface{}) map[string]interface{} {
🤖 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/db_common.go` around lines 37 - 45, The logic in dbEnvParams
is fine, but its doc comment is written in Chinese while the surrounding
codebase uses English. Translate the comment above dbEnvParams into concise
English, keeping the same meaning about only setting env when dbEnv(rctx) is
non-empty and otherwise omitting it for server-side default selection.
🤖 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_data_import.go`:
- Line 79: The dry-run test for the omitted --environment path only verifies the
derived table name and should also assert the default env behavior. Update
TestAppsDBDataImport_TableDefaultsToFileBasename to check the request shape
produced by dbEnvParams and Params, specifically that env is unset/defaulted in
the dry-run case when no environment is provided, so the default handling stays
covered.

In `@shortcuts/apps/apps_db_quota_get.go`:
- Around line 44-51: The +db-quota-get command currently builds its request
without an explicit dry-run assertion for the omitted env case. Update the
quota-get flow in Execute and the related tests so that when --environment is
not provided, dbEnvParams receives an empty map and the API request is verified
to omit env entirely. Add this coverage alongside the existing quota-get tests
in apps_db_env_recovery_quota_test.go, using appDbQuotaPath, dbEnvParams, and
rctx.CallAPITyped as the key symbols to locate the change.

---

Duplicate comments:
In `@shortcuts/apps/apps_db_audit_list.go`:
- Around line 217-231: Confirm the no-`--environment` dry-run path is covered by
a test, since `buildAuditListParams`, `fetchExistingTables`, and
`fetchAuditEnabledTables` now omit `env` by default. Update
`shortcuts/apps/apps_db_audit_test.go` to assert the generated params for the
unset-environment case, including that `env` is absent when the flag is not
provided. Keep the test aligned with the existing dry-run coverage and verify
the behavior through the same audit-list parameter builder flow.

In `@shortcuts/apps/apps_db_changelog_list.go`:
- Around line 79-82: The changelog parameter builder in buildChangelogParams now
defaults unset environment handling, but the tests only cover the env=dev path.
Add or update coverage in shortcuts/apps/apps_db_changelog_list_test.go for the
no--environment case to verify the dry-run/default behavior matches the new
dbEnvParams logic and the fallback environment is applied correctly.

---

Nitpick comments:
In `@shortcuts/apps/db_common.go`:
- Around line 37-45: The logic in dbEnvParams is fine, but its doc comment is
written in Chinese while the surrounding codebase uses English. Translate the
comment above dbEnvParams into concise English, keeping the same meaning about
only setting env when dbEnv(rctx) is non-empty and otherwise omitting it for
server-side default selection.
🪄 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: 6796977b-3223-4f0d-b3ea-2ea893b9245c

📥 Commits

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

📒 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
  • shortcuts/apps/db_common.go
  • 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.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/cli_e2e/apps/apps_db_table_list_dryrun_test.go
  • shortcuts/apps/apps_db_audit_status.go
  • shortcuts/apps/apps_db_audit_set.go

POST(appDataImportPath(appID)).
Desc("Import data file into Miaoda app table (multipart upload)").
Params(map[string]interface{}{"env": dbEnv(rctx), "table": importTableName(rctx)}).
Params(dbEnvParams(rctx, map[string]interface{}{"table": importTableName(rctx)})).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 'env|environment' shortcuts/apps/apps_db_data_import_test.go

Repository: larksuite/cli

Length of output: 2062


🏁 Script executed:

#!/bin/bash
sed -n '1,260p' shortcuts/apps/apps_db_data_import_test.go

Repository: larksuite/cli

Length of output: 6382


Add an assertion for the default env in the omitted---environment dry-run case. TestAppsDBDataImport_TableDefaultsToFileBasename only checks the derived table name; it should also cover the new unset-env default so the dry-run request shape doesn’t regress.

🤖 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/apps_db_data_import.go` at line 79, The dry-run test for the
omitted --environment path only verifies the derived table name and should also
assert the default env behavior. Update
TestAppsDBDataImport_TableDefaultsToFileBasename to check the request shape
produced by dbEnvParams and Params, specifically that env is unset/defaulted in
the dry-run case when no environment is provided, so the default handling stays
covered.

Source: Coding guidelines

Comment on lines +44 to +51
Params(dbEnvParams(rctx, map[string]interface{}{}))
},
Execute: func(ctx context.Context, rctx *common.RuntimeContext) error {
appID, err := requireAppID(rctx.Str("app-id"))
if err != nil {
return err
}
data, err := rctx.CallAPITyped("GET", appDbQuotaPath(appID), map[string]interface{}{"env": dbEnv(rctx)}, nil)
data, err := rctx.CallAPITyped("GET", appDbQuotaPath(appID), dbEnvParams(rctx, map[string]interface{}{}), nil)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd -a 'apps_db_quota_get.*test.*\.go'
rg -n -C3 'env|environment' shortcuts/apps/apps_db_quota_get_test.go 2>/dev/null

Repository: larksuite/cli

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files matching apps_db_quota_get test patterns:\n'
fd -a 'apps_db_quota_get' shortcuts 2>/dev/null || true
printf '\nAll tests under shortcuts/apps related to db quota:\n'
fd -a 'db_quota' shortcuts/apps 2>/dev/null || true
printf '\nDirect listing of relevant files:\n'
git ls-files 'shortcuts/apps/*quota*' 'shortcuts/apps/*dryrun*' 'shortcuts/apps/*db*test*.go'

Repository: larksuite/cli

Length of output: 930


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the exact file and nearby tests, then inspect just the relevant slices.
git ls-files 'shortcuts/apps/*.go' | rg 'apps_db_(quota|get|execute|table_list).*test|apps_db_quota_get\.go|apps_db_execute_dryrun_test\.go|apps_db_table_list_dryrun_test\.go'

Repository: larksuite/cli

Length of output: 268


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
root = Path('.')
matches = []
for p in root.rglob('*.go'):
    s = p.as_posix()
    if 'shortcuts/apps/' in s and ('quota' in s or 'dryrun' in s or 'table_list' in s or 'execute' in s):
        matches.append(s)
for s in sorted(matches):
    print(s)
PY

Repository: larksuite/cli

Length of output: 470


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'apps_db_quota_get.go outline:\n'
ast-grep outline shortcuts/apps/apps_db_quota_get.go --view expanded || true

printf '\nRelevant test file outlines:\n'
ast-grep outline shortcuts/apps/apps_db_execute_test.go --view expanded || true
printf '\n---\n'
ast-grep outline shortcuts/apps/apps_db_table_list_test.go --view expanded || true

printf '\nSearch for quota path/env parameter usage:\n'
rg -n 'appDbQuotaPath|dbEnvParams|env' shortcuts/apps/apps_db_quota_get.go shortcuts/apps/apps_db_execute_test.go shortcuts/apps/apps_db_table_list_test.go shortcuts/apps/*.go

Repository: larksuite/cli

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Read apps_db_quota_get.go around the Execute function:\n'
cat -n shortcuts/apps/apps_db_quota_get.go | sed -n '1,120p'

printf '\nRead relevant slices from db execute/table list tests:\n'
cat -n shortcuts/apps/apps_db_execute_test.go | sed -n '1,260p'
printf '\n---\n'
cat -n shortcuts/apps/apps_db_table_list_test.go | sed -n '1,260p'

Repository: larksuite/cli

Length of output: 26313


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Find all tests asserting env omission/default behavior in shortcuts/apps:\n'
rg -n -C 2 'omitempty|omit.*env|env parameter|Params\(dbEnvParams|dbEnvParams\(' shortcuts/apps/*test.go

printf '\nFind any direct tests for apps_db_quota_get command:\n'
rg -n -C 3 'quota-get|db_quota|get quota|appDbQuotaPath' shortcuts/apps/*test.go shortcuts/apps/*.go

Repository: larksuite/cli

Length of output: 12824


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the current implementation and nearby tests in small slices.
cat -n shortcuts/apps/apps_db_quota_get.go | sed -n '1,120p'

printf '\n--- apps_db_execute_test.go ---\n'
cat -n shortcuts/apps/apps_db_execute_test.go | sed -n '1,220p'

printf '\n--- apps_db_table_list_test.go ---\n'
cat -n shortcuts/apps/apps_db_table_list_test.go | sed -n '1,220p'

Repository: larksuite/cli

Length of output: 23339


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 3 'dbEnvParams|appDbQuotaPath|quota-get|db-quota-get|env' shortcuts/apps/apps_db_execute_test.go shortcuts/apps/apps_db_table_list_test.go shortcuts/apps/apps_db_quota_get.go shortcuts/apps/*test.go

Repository: larksuite/cli

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the db quota tests directly; focus on the two AppsDBQuotaGet cases.
cat -n shortcuts/apps/apps_db_env_recovery_quota_test.go | sed -n '297,360p'

printf '\nSearch for env omission assertions in quota tests:\n'
rg -n -C 2 'Params\["env"\]|omit|absent|not send|db-quota-get|AppsDBQuotaGet' shortcuts/apps/apps_db_env_recovery_quota_test.go

Repository: larksuite/cli

Length of output: 4779


Add a dry-run check for +db-quota-get's omitted env. The quota-get tests in shortcuts/apps/apps_db_env_recovery_quota_test.go cover output shape, but not that the request omits env when --environment is left unset.

🤖 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/apps_db_quota_get.go` around lines 44 - 51, The +db-quota-get
command currently builds its request without an explicit dry-run assertion for
the omitted env case. Update the quota-get flow in Execute and the related tests
so that when --environment is not provided, dbEnvParams receives an empty map
and the API request is verified to omit env entirely. Add this coverage
alongside the existing quota-get tests in apps_db_env_recovery_quota_test.go,
using appDbQuotaPath, dbEnvParams, and rctx.CallAPITyped as the key symbols to
locate the change.

Source: Coding guidelines

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