fix: support field create json array input - #1661
Conversation
📝 WalkthroughWalkthrough
ChangesField Create Array Batch Support
Sequence Diagram(s)sequenceDiagram
participant CLI
participant parseFieldCreateBodies
participant executeFieldCreate
participant LarkBaseAPI
CLI->>parseFieldCreateBodies: --json array
parseFieldCreateBodies-->>executeFieldCreate: []fieldBody
loop for each fieldBody
executeFieldCreate->>LarkBaseAPI: POST /fields (body)
LarkBaseAPI-->>executeFieldCreate: created field
executeFieldCreate->>executeFieldCreate: sleep(fieldCreateBatchDelay)
end
executeFieldCreate-->>CLI: field (n=1) or fields+total (n>1)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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: 3
🤖 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/base/base_execute_test.go`:
- Around line 1100-1146: Add a new fail-fast batch error subtest in the existing
BaseFieldCreate test suite, alongside the current “create array sequentially”
case, to cover the changed command contract. Use the same helpers and symbols
like runShortcut, BaseFieldCreate, newExecuteFactory, and the
/open-apis/base/v3/bases/app_x/tables/tbl_x/fields stubs, but make the second
POST /fields return a typed API error and assert the command stops immediately,
does not continue to any later requests, and does not roll back earlier
successes.
In `@shortcuts/base/base_shortcuts_test.go`:
- Around line 1066-1070: The new negative assertions in BaseFieldCreate.Validate
only check err.Error() text, so switch them to typed error checks instead. Use
errs.ProblemOf on the validation failures from BaseFieldCreate.Validate to
assert the problem category/subtype, and add errors.As against
*errs.ValidationError when you need to verify Param for the --json case. Keep
the existing scenarios, but stop relying on message substrings alone and ensure
the test covers the structured error metadata and cause preservation.
In `@tests/cli_e2e/base/base_field_dryrun_test.go`:
- Around line 35-44: The dry-run assertions in base_field_dryrun_test.go only
validate api.0 and api.1, so extra emitted requests could still slip through;
update the test around the result.Stdout checks to first assert the API call
array length is exactly two, then keep the existing validations for the entries
using gjson.Get on api.0 and api.1. Use the same result.Stdout and gjson-based
assertions in the test to locate the spot and make the expectation explicit.
🪄 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: d0287631-d75f-49b0-b92c-7fb0c7fb71d9
📒 Files selected for processing (7)
shortcuts/base/base_dryrun_ops_test.goshortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/field_ops.goskills/lark-base/references/lark-base-field-json.mdtests/cli_e2e/base/base_field_dryrun_test.gotests/cli_e2e/base/coverage.md
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@1339162c2437debce4ab1641feb03ad47cff6fca🧩 Skill updatenpx skills add zgz2048/cli#codex/base-field-create-json-array -y -g |
Summary
base +field-create --jsonto accept an internal compatibility array of field JSON objects while preserving the existing single-object path and output shape.style.formatcontrols frontend display while stored time values can retain seconds precision.Validation
make buildgo test ./shortcuts/base -run 'TestBaseFieldValidate|TestDryRunFieldOps|TestBaseObjectJSONShortcutsRejectArrayInDryRun|TestBaseFieldExecuteCRUD'\n-go test ./tests/cli_e2e/base -run TestBaseFieldCreateDryRunArrayCompatSummary by CodeRabbit
New Features
Bug Fixes
Documentation