Skip to content

feat(base): add record batch add/set shortcuts#277

Merged
kongenpei merged 16 commits intomainfrom
feat/base-record-batch-shortcuts
Apr 10, 2026
Merged

feat(base): add record batch add/set shortcuts#277
kongenpei merged 16 commits intomainfrom
feat/base-record-batch-shortcuts

Conversation

@kongenpei
Copy link
Copy Markdown
Collaborator

@kongenpei kongenpei commented Apr 6, 2026

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

  • Add new shortcuts: +record-batch-add and +record-batch-set
  • Implement dry-run and execute handlers in record_ops.go for both commands
  • Register new shortcuts in shortcuts/base/shortcuts.go
  • Extend tests in base_shortcuts_test.go, base_dryrun_ops_test.go, and base_execute_test.go
  • Update lark-base skill docs and record reference pages for the new commands
  • Fix cmd/config/show.go to return real load errors while keeping missing-config hint behavior
  • Add cmd/config/show_run_test.go coverage for invalid/missing config paths

Test Plan

  • Unit tests pass (make unit-test)
  • Lint passes (golangci-lint --new-from-rev=origin/main)
  • Manual local verification confirms the target lark command works as expected

Related Issues

Summary by CodeRabbit

  • New Features

    • Added +record-batch-create and +record-batch-update for bulk record create/update (up to 200 records).
  • Documentation

    • New detailed guides for both batch commands; updated record-writing rules and examples.
  • Tests

    • Expanded dry-run and execution tests covering batch create/update flows and CLI output.
  • Shortcuts

    • CLI catalog now shows the two batch shortcuts next to record upsert.
  • Behavior

    • Validation behavior for record upsert and batch commands adjusted (explicit JSON validation step removed).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Shortcuts Registry & New Shortcut Definitions
shortcuts/base/shortcuts.go, shortcuts/base/record_batch_create.go, shortcuts/base/record_batch_update.go, shortcuts/base/record_upsert.go
Registered BaseRecordBatchCreate and BaseRecordBatchUpdate immediately after BaseRecordUpsert; removed the explicit Validate call from BaseRecordUpsert.
Batch Handlers & Ops
shortcuts/base/record_ops.go, shortcuts/base/record_batch_create.go, shortcuts/base/record_batch_update.go
Added dryRunRecordBatchCreate/dryRunRecordBatchUpdate and executeRecordBatchCreate/executeRecordBatchUpdate; removed validateRecordJSON. Handlers call base V3 raw endpoints for batch create/update and format outputs.
Tests
shortcuts/base/base_dryrun_ops_test.go, shortcuts/base/base_execute_test.go, shortcuts/base/base_shortcuts_test.go
Extended dry-run tests to assert batch-create/batch-update requests and added execute subtests for batch-create, batch-update, and passthrough behavior; adjusted shortcut catalog and validation expectations.
Documentation / Skills
skills/lark-base/SKILL.md, skills/lark-base/references/lark-base-record.md, skills/lark-base/references/lark-base-record-batch-create.md, skills/lark-base/references/lark-base-record-batch-update.md
Documented two new commands, JSON shapes (fields+rows, record_id_list+patch), usage guidance, limits (max 200 rows/ids), and updated rules about forbidden/atomic write fields.
New Reference Docs
skills/lark-base/references/lark-base-record-batch-create.md, skills/lark-base/references/lark-base-record-batch-update.md
Added standalone reference pages describing endpoints, request/response shapes, examples, and caveats for batch create/update.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size/L, domain/ccm

Suggested reviewers

  • liujinkun2025
  • fangshuyu-768

Poem

🐰 I hopped through lines both neat and quick,

Two batch commands I helped to pick.
POST the rows, PATCH the list,
Fields aligned, no step we missed.
Tiny paws — a tidy trick!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description lacks a Test Plan section with checkboxes despite the template requiring it, and includes a bonus fix to cmd/config/show.go that is not reflected in the raw_summary. Clarify whether the config/show.go fix is in scope, confirm all unit/manual tests were actually run with checkboxes, and verify the command names align with the actual implementation (batch-create/batch-update vs batch-add/batch-set terminology).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding two new batch shortcuts (+record-batch-create and +record-batch-update) for record operations in the Base service.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/base-record-batch-shortcuts

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

@github-actions github-actions Bot added domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels Apr 6, 2026
@kongenpei kongenpei requested a review from zgz2048 April 6, 2026 12:25
@kongenpei kongenpei force-pushed the feat/base-record-batch-shortcuts branch from 2150233 to 56be462 Compare April 8, 2026 07:07
@github-actions github-actions Bot added size/L Large or sensitive change across domains or core paths and removed size/M Single-domain feat or fix with limited business impact labels Apr 8, 2026
@kongenpei kongenpei force-pushed the feat/base-record-batch-shortcuts branch from 9c2512f to 6d38c9e Compare April 8, 2026 09:34
@github-actions github-actions Bot added size/M Single-domain feat or fix with limited business impact and removed size/L Large or sensitive change across domains or core paths labels Apr 8, 2026
@kongenpei kongenpei marked this pull request as ready for review April 8, 2026 09:52
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 8, 2026

Greptile Summary

Adds +record-batch-create and +record-batch-update shortcuts for the Base v3 batch write APIs, each wiring dry-run, execute, flags, and skill documentation in the established pattern. The PR also removes the previously no-op Validate hook from BaseRecordUpsert, moving JSON-parse error handling uniformly into the execution layer via parseJSONObject.

Confidence Score: 5/5

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

Vulnerabilities

No security concerns identified. The new batch endpoints follow the same auth/scope pattern as existing record commands (base:record:create, base:record:update), user-supplied JSON is parsed through the existing parseJSONObject helper before being forwarded, and no credentials or sensitive data are logged.

Important Files Changed

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)
Loading

Reviews (6): Last reviewed commit: "fix(base): pass parse context for record..." | Re-trigger Greptile

Comment thread shortcuts/base/record_ops.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 8, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/base-record-batch-shortcuts -y -g

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 http or text as 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.md around 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., change tohttp 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., change tohttp 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 -->

Comment thread shortcuts/base/record_ops.go Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-create.md
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-set.md Outdated
Comment thread skills/lark-base/SKILL.md Outdated
Comment thread skills/lark-base/SKILL.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-add.md Outdated
Comment thread skills/lark-base/references/lark-base-record-batch-set.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d9b2c2 and ebb0ea9.

📒 Files selected for processing (11)
  • shortcuts/base/base_dryrun_ops_test.go
  • shortcuts/base/base_execute_test.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/record_batch_create.go
  • shortcuts/base/record_batch_update.go
  • shortcuts/base/record_ops.go
  • shortcuts/base/shortcuts.go
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-record-batch-create.md
  • skills/lark-base/references/lark-base-record-batch-update.md
  • skills/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

Comment thread shortcuts/base/record_batch_create.go Outdated
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

zgz2048
zgz2048 previously approved these changes Apr 10, 2026
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

zgz2048
zgz2048 previously approved these changes Apr 10, 2026
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

kongenpei has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@kongenpei kongenpei merged commit fa16fe1 into main Apr 10, 2026
15 checks passed
@kongenpei kongenpei deleted the feat/base-record-batch-shortcuts branch April 10, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base domain 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