feat(base): add record batch add/set shortcuts#277
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds two new batch record shortcuts (+record-batch-create, +record-batch-update), implements their dry-run and execution handlers, updates tests and docs for batch operations, registers the shortcuts, and removes an unused record JSON validation function. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User (CLI)
participant CLI as lark-cli
participant Runtime as RuntimeContext
participant API as Base API (/open-apis/base/v3)
User->>CLI: run +record-batch-create / +record-batch-update (--json ...)
CLI->>Runtime: invoke DryRun or Execute handler
Runtime->>API: POST /bases/:base_token/tables/:table_id/records/batch_create (body)
API-->>Runtime: response (record_id_list, fields, data, ...)
Runtime-->>CLI: format and write output
CLI-->>User: stdout/stderr
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
2150233 to
56be462
Compare
9c2512f to
6d38c9e
Compare
Greptile SummaryAdds Confidence Score: 5/5Safe to merge — implementation is correct and consistent with existing patterns; the only finding is a minor test-coverage gap. All findings are P2 (style/test gap). The core logic correctly passes the baseV3Raw error into handleBaseAPIResult, JSON validation is handled uniformly at execution time, scopes are accurate, and dry-run URLs match the API paths. No correctness, data-integrity, or security issues were found. base_execute_test.go — the batch create sub-test is missing a request-body passthrough assertion analogous to the batch update passthrough test.
|
| Filename | Overview |
|---|---|
| shortcuts/base/record_ops.go | Adds dryRunRecordBatchCreate/Update and executeRecordBatchCreate/Update; uses baseV3Raw + handleBaseAPIResult two-line pattern consistently; JSON parsing and error propagation are correct. |
| shortcuts/base/record_batch_create.go | New file defining BaseRecordBatchCreate shortcut with correct scopes, flags, and wiring to dryRun/Execute handlers. |
| shortcuts/base/record_batch_update.go | New file defining BaseRecordBatchUpdate shortcut; scope set to base:record:update, descriptive --json flag, correct handler wiring. |
| shortcuts/base/record_upsert.go | Removes the now-redundant Validate hook from BaseRecordUpsert; invalid JSON is caught downstream in executeRecordUpsert via parseJSONObject, which is consistent with batch command behavior. |
| shortcuts/base/shortcuts.go | Registers BaseRecordBatchCreate and BaseRecordBatchUpdate in the catalog in the correct position (after upsert, before upload-attachment). |
| shortcuts/base/base_execute_test.go | Adds batch create, batch update, and batch update passthrough tests; the passthrough test correctly captures and asserts the request body, but the batch create test lacks a corresponding body-verification sub-test. |
| shortcuts/base/base_dryrun_ops_test.go | Adds dry-run assertions for batch_create and batch_update URL patterns; concise and correct. |
| shortcuts/base/base_shortcuts_test.go | Updates catalog test to include new commands and replaces the old Validate execution test with nil-checks confirming validation is intentionally absent from upsert and batch commands. |
| skills/lark-base/SKILL.md | Extends prohibitions, mental model, core rules, and reference table to include the two new batch commands; changes are consistent and complete. |
| skills/lark-base/references/lark-base-record-batch-create.md | New reference page documenting batch-create request/response shape, 200-row limit, and field-ordering pitfalls; thorough and accurate. |
| skills/lark-base/references/lark-base-record-batch-update.md | New reference page documenting batch-update semantics (single patch applied to all record_id_list entries), 200-record limit, and passthrough behavior. |
| skills/lark-base/references/lark-base-record.md | Index page updated to link to the two new reference docs in the correct position within the table. |
Sequence Diagram
sequenceDiagram
participant CLI as lark-cli
participant RT as RuntimeContext
participant API as Lark Base API
Note over CLI,API: +record-batch-create
CLI->>RT: parseJSONObject(--json)
RT-->>CLI: body {fields, rows}
CLI->>API: POST /base/v3/bases/:token/tables/:id/records/batch_create
API-->>CLI: {code:0, data:{fields,record_id_list,data}}
CLI->>RT: handleBaseAPIResult → Out(data)
Note over CLI,API: +record-batch-update
CLI->>RT: parseJSONObject(--json)
RT-->>CLI: body {record_id_list, patch}
CLI->>API: POST /base/v3/bases/:token/tables/:id/records/batch_update
API-->>CLI: {code:0, data:{has_more,record_id_list,update}}
CLI->>RT: handleBaseAPIResult → Out(data)
Reviews (6): Last reviewed commit: "fix(base): pass parse context for record..." | Re-trigger Greptile
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@2208bcc8d09e76a93b59182a3a5a25cd73761f60🧩 Skill updatenpx skills add larksuite/cli#feat/base-record-batch-shortcuts -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
skills/lark-base/references/lark-base-record-batch-add.md (1)
33-35: Add language identifier to fenced code block.The fenced code block for the HTTP method and path is missing a language specification. Consider adding
httportextas the language identifier.-``` +```http POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch<details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@skills/lark-base/references/lark-base-record-batch-add.mdaround lines 33 -
35, The fenced code block showing the HTTP method and path (the block containing
"POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch") is
missing a language hint; update that triple-backtick fence to include a language
identifier (e.g., changetohttp or ```text) so the snippet is annotated
for syntax/highlight rendering.</details> </blockquote></details> <details> <summary>skills/lark-base/references/lark-base-record-batch-set.md (1)</summary><blockquote> `32-34`: **Add language identifier to fenced code block.** Similar to the batch-add documentation, the fenced code block for the HTTP method and path is missing a language specification. ```diff -``` +```http PATCH /open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch ``` ``` <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against the current code and only fix it if needed. In `@skills/lark-base/references/lark-base-record-batch-set.md` around lines 32 - 34, The fenced code block containing the HTTP method/path "PATCH /open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch" lacks a language identifier; update that fenced block to include the language tag (e.g., add "http" after the opening backticks) so it matches the style used in the batch-add documentation and enables proper syntax highlighting. ``` </details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@shortcuts/base/record_ops.go:
- Around line 149-175: executeRecordBatchAdd and executeRecordBatchSet accept
parsed JSON but don't validate required command-specific keys, so malformed
payloads reach the API; after parseJSONObject in each function, add schema
guards: in executeRecordBatchAdd ensure the body has "fields" (object/map) and
"rows" (array) with correct basic types, and in executeRecordBatchSet ensure the
body has "record_id_list" (array) and "patch" (object/array as expected); if
validation fails return a clear error before calling baseV3Raw; keep using the
same error-return flow and helpers (parseJSONObject, baseV3Raw,
handleBaseAPIResult) and reference baseTableID(runtime) as before.
Nitpick comments:
In@skills/lark-base/references/lark-base-record-batch-add.md:
- Around line 33-35: The fenced code block showing the HTTP method and path (the
block containing "POST
/open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch") is missing
a language hint; update that triple-backtick fence to include a language
identifier (e.g., changetohttp or ```text) so the snippet is annotated
for syntax/highlight rendering.In
@skills/lark-base/references/lark-base-record-batch-set.md:
- Around line 32-34: The fenced code block containing the HTTP method/path
"PATCH /open-apis/base/v3/bases/:base_token/tables/:table_id/records/batch"
lacks a language identifier; update that fenced block to include the language
tag (e.g., add "http" after the opening backticks) so it matches the style used
in the batch-add documentation and enables proper syntax highlighting.</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `e1472145-0604-4eea-a0c1-c5a4a853b52f` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between f5a8fbf8f1da133b812fe8805e861bc516f4e35b and 8d9b2c2be0d18ca3b9c8219c7f9b38d2b985ca5b. </details> <details> <summary>📒 Files selected for processing (11)</summary> * `shortcuts/base/base_dryrun_ops_test.go` * `shortcuts/base/base_execute_test.go` * `shortcuts/base/base_shortcuts_test.go` * `shortcuts/base/record_batch_add.go` * `shortcuts/base/record_batch_set.go` * `shortcuts/base/record_ops.go` * `shortcuts/base/shortcuts.go` * `skills/lark-base/SKILL.md` * `skills/lark-base/references/lark-base-record-batch-add.md` * `skills/lark-base/references/lark-base-record-batch-set.md` * `skills/lark-base/references/lark-base-record.md` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/record_batch_create.go`:
- Around line 24-26: The Validate hook in record_batch_create.go is delegating
to validateRecordJSON which currently always returns nil; update
validateRecordJSON (in record_ops.go) to actually parse and validate the
incoming --json payload and return a descriptive error on parse/validation
failures, or replace the Validate implementation to call a new validator that
performs JSON unmarshalling and schema checks; ensure the Validate function
referenced in record_batch_create.go returns the error from validateRecordJSON
so malformed JSON is rejected during validation.
🪄 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: aa2879d3-4bf0-4278-969d-a32cce17a354
📒 Files selected for processing (11)
shortcuts/base/base_dryrun_ops_test.goshortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/record_batch_create.goshortcuts/base/record_batch_update.goshortcuts/base/record_ops.goshortcuts/base/shortcuts.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-record-batch-create.mdskills/lark-base/references/lark-base-record-batch-update.mdskills/lark-base/references/lark-base-record.md
✅ Files skipped from review due to trivial changes (5)
- shortcuts/base/base_shortcuts_test.go
- skills/lark-base/references/lark-base-record.md
- shortcuts/base/shortcuts.go
- skills/lark-base/references/lark-base-record-batch-update.md
- skills/lark-base/references/lark-base-record-batch-create.md
🚧 Files skipped from review as they are similar to previous changes (3)
- shortcuts/base/base_dryrun_ops_test.go
- shortcuts/base/base_execute_test.go
- shortcuts/base/record_ops.go
…h-shortcuts # Conflicts: # skills/lark-base/SKILL.md
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Summary
Add base +record-batch-add and base +record-batch-set shortcuts for Base v3 batch write APIs, and include a follow-up config show error-handling fix so invalid config errors are not swallowed.
Changes
Test Plan
Related Issues
Summary by CodeRabbit
New Features
Documentation
Tests
Shortcuts
Behavior