Skip to content

feat: support .base import and export for bitable#599

Merged
fangshuyu-768 merged 1 commit intomainfrom
feat/bitable-base-import-export
Apr 22, 2026
Merged

feat: support .base import and export for bitable#599
fangshuyu-768 merged 1 commit intomainfrom
feat/bitable-base-import-export

Conversation

@liujinkun2025
Copy link
Copy Markdown
Collaborator

@liujinkun2025 liujinkun2025 commented Apr 22, 2026

Summary

Add .base import/export support for bitable in the drive shortcuts.
This lets users export a bitable snapshot to .base and import a .base snapshot back into bitable with matching validation and docs.

Changes

  • add base as a supported --file-extension for drive +export and restrict it to --doc-type bitable
  • allow .base files in drive +import, enforce the 20 MB size limit, and keep import/export filenames aligned with the .base suffix
  • update the lark-drive references and add unit coverage for validation and file-size checks

Test Plan

  • Unit tests pass (go test ./shortcuts/drive)
  • Manual local verification confirms the lark xxx command works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added support for exporting to .base snapshots (Bitable-only) and importing .base files as Bitable; CLI flags now accept base and enforce Bitable-only where applicable.
  • Documentation

    • Added examples, guidance, and a 20MB import size limit for .base; clarified compatibility and usage flows.
  • Tests

    • Added unit and end-to-end tests for .base export/import, validation, filename handling, and size-limit enforcement.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7d0fd3b-06a4-4b7a-a676-e81be940518f

📥 Commits

Reviewing files that changed from the base of the PR and between 7bdf03b and 16c9ed6.

📒 Files selected for processing (13)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_common_test.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_import.go
  • shortcuts/drive/drive_import_common.go
  • shortcuts/drive/drive_import_common_test.go
  • skill-template/domains/base.md
  • skill-template/domains/drive.md
  • skills/lark-base/SKILL.md
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md
  • skills/lark-drive/references/lark-drive-import.md
✅ Files skipped from review due to trivial changes (8)
  • skill-template/domains/drive.md
  • shortcuts/drive/drive_import.go
  • skills/lark-drive/SKILL.md
  • shortcuts/drive/drive_export_common_test.go
  • skills/lark-base/SKILL.md
  • shortcuts/drive/drive_export_common.go
  • skill-template/domains/base.md
  • skills/lark-drive/references/lark-drive-import.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/drive/drive_import_common.go

📝 Walkthrough

Walkthrough

Adds .base (bitable snapshot) support to Drive import/export: CLI flag enums/descriptions, validation (export/import), export filename suffix mapping, 20MB import size limit for .base, tests, and documentation. No other control flow or external API behavior changed.

Changes

Cohort / File(s) Summary
Export Flag & Metadata
shortcuts/drive/drive_export.go
Added base to --file-extension enum and updated help to note (bitable only).
Export Validation & Helpers
shortcuts/drive/drive_export_common.go, shortcuts/drive/drive_export_common_test.go
Accept "base" in validation, require DocType == "bitable" for base, map base".base", and add unit tests for suffix/extension behavior.
Export Integration Tests
shortcuts/drive/drive_export_test.go
Added async test stubbing export task with file_extension:"base", asserting POST payload and downloaded crm.base content.
Import Flag Text
shortcuts/drive/drive_import.go
Updated file flag help to include .base and mention 20MB cap.
Import Validation & Limits
shortcuts/drive/drive_import_common.go, shortcuts/drive/drive_import_common_test.go
Map .basebitable, apply 20MB text-like upload path, refine validation messages/hints, and add unit/integration tests including oversized .base.
Documentation & Skills
skills/.../lark-drive/references/*, skill-template/domains/*, skills/lark-base/SKILL.md, skills/lark-drive/SKILL.md
Added examples and guidance for .base import/export, documented .base → bitable mapping, bitable-only constraint, and 20MB import limit across docs and skill routing guidance.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Client (CLI)
    participant API as Drive API
    participant Disk as Local Disk
    rect rgba(200,230,255,0.5)
    CLI->>API: POST /open-apis/drive/v1/export_tasks {type: "bitable", file_extension: "base"}
    API-->>CLI: {ticket}
    CLI->>API: GET /open-apis/drive/v1/export_tasks/{ticket} (poll until done)
    API-->>CLI: {status: "success", snapshot_url}
    CLI->>API: GET snapshot_url
    API-->>CLI: binary snapshot (Content-Disposition: crm.base)
    CLI->>Disk: write "crm.base"
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • fangshuyu-768
  • zhouyue-bytedance

Poem

🐰 I hopped through code to add a little base,
Bitable snapshots now find their place,
Twenty meg cap keeps the stash in line,
Exported, imported — crm.base shines,
A tiny hop, a perfect trace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding support for .base import and export functionality for bitable documents.
Description check ✅ Passed The description covers all template sections with sufficient detail: includes summary, comprehensive list of changes, test plan with both unit tests and manual verification noted, and related issues section.
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.

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

✨ 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 feat/bitable-base-import-export

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 and usage tips.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.96%. Comparing base (3e5dc32) to head (16c9ed6).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #599      +/-   ##
==========================================
- Coverage   61.69%   59.96%   -1.74%     
==========================================
  Files         402      405       +3     
  Lines       35073    42680    +7607     
==========================================
+ Hits        21639    25592    +3953     
- Misses      11429    15080    +3651     
- Partials     2005     2008       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/bitable-base-import-export -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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/lark-drive/references/lark-drive-import.md (1)

66-75: ⚠️ Potential issue | 🟡 Minor

Add .base to the mismatch rules list.

Line 66 adds .base support, but the validation guidance below still omits the .basebitable-only rule.

📝 Proposed documentation update
 > - `.xlsx` / `.csv` 文件**只能**导入为 `sheet` 或 `bitable`
 > - `.xls` 文件**只能**导入为 `sheet`
+> - `.base` 文件**只能**导入为 `bitable`
 > - 例如:`.csv` 文件不能导入为 `docx`,`.md` 文件不能导入为 `sheet`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-drive/references/lark-drive-import.md` around lines 66 - 75,
Update the validation rules to include the new `.base` extension and state it
can only be imported as `bitable`: add an explicit rule mapping `.base` →
`bitable` alongside the other extension constraints, and ensure the explanatory
note references the CLI flag `--type bitable` (and the user synonyms
"Base"/"多维表格"/"bitable") so docs consistently enforce that `.base` files are
accepted only when `--type bitable` is used.
🤖 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/drive/drive_export.go`:
- Line 34: The enum for the "file-extension" option in drive_export.go currently
includes "base", which is not supported by Lark Drive v1 export_tasks and will
cause runtime failures; remove "base" from the Enum slice in the option
definition where Name: "file-extension" and Desc: "export format..." is defined
(leave only "docx","pdf","xlsx","csv","markdown"), and if you intended to
support a new type ensure OAuth scope/type changes and API compatibility before
re-adding. Also add a dry-run E2E test under tests/cli_e2e/dryrun/ that invokes
the export shortcut command in dry-run mode and asserts the generated
command/flags include the corrected file-extension enum values (no "base") to
prevent regressions.

In `@shortcuts/drive/drive_import.go`:
- Line 30: Add a dry-run E2E test exercising the drive +import flow by creating
a sample .base file(s) and invoking the CLI with the same flags as the command
definition (the "file" flag described in shortcuts/drive/drive_import.go) using:
drive +import --file <sample>.base --type bitable --dry-run; place the test
under tests/cli_e2e/drive/ (or tests/cli_e2e/dryrun/) and ensure it (1) creates
a valid .base payload under the 20MB cap and asserts the CLI returns the
expected dry-run request structure (headers/body) without calling real APIs, and
(2) includes a negative case where a .base file >20MB is provided and the CLI
fails with the size-limit error; keep the test purely dry-run/mocked so no
external network calls occur.

---

Outside diff comments:
In `@skills/lark-drive/references/lark-drive-import.md`:
- Around line 66-75: Update the validation rules to include the new `.base`
extension and state it can only be imported as `bitable`: add an explicit rule
mapping `.base` → `bitable` alongside the other extension constraints, and
ensure the explanatory note references the CLI flag `--type bitable` (and the
user synonyms "Base"/"多维表格"/"bitable") so docs consistently enforce that `.base`
files are accepted only when `--type bitable` is used.
🪄 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: 63821b7b-8eac-4676-9217-95f1d92cc538

📥 Commits

Reviewing files that changed from the base of the PR and between 11191df and 1f9c808.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_common_test.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_import.go
  • shortcuts/drive/drive_import_common.go
  • shortcuts/drive/drive_import_common_test.go
  • skills/lark-drive/references/lark-drive-export.md
  • skills/lark-drive/references/lark-drive-import.md

Comment thread shortcuts/drive/drive_export.go
Comment thread shortcuts/drive/drive_import.go
@liujinkun2025 liujinkun2025 force-pushed the feat/bitable-base-import-export branch 2 times, most recently from 0ad0b90 to a94697a Compare April 22, 2026 06:48
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/lark-drive/references/lark-drive-export.md (1)

4-6: ⚠️ Potential issue | 🟡 Minor

Fix markdownlint MD028 (blank line in blockquote).

There is a blank line immediately after the blockquote line, which triggers MD028. Remove the blank line or keep the following paragraph inside the same blockquote.

🧹 Proposed markdown lint fix
 > **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。
-
 把 `doc` / `docx` / `sheet` / `bitable` 导出到本地文件。这个 shortcut 内置有限轮询:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-drive/references/lark-drive-export.md` around lines 4 - 6, The
blockquote line starting with "**前置条件:** 先阅读
[`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。" is
followed by a blank line which triggers markdownlint MD028; remove that blank
line or merge the subsequent paragraph ("把 `doc` / `docx` / `sheet` / `bitable`
导出到本地文件。这个 shortcut 内置有限轮询:") into the same blockquote so the content remains
one continuous blockquote (edit the lines around the blockquote marker to
eliminate the empty line).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@skills/lark-drive/references/lark-drive-export.md`:
- Around line 4-6: The blockquote line starting with "**前置条件:** 先阅读
[`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。" is
followed by a blank line which triggers markdownlint MD028; remove that blank
line or merge the subsequent paragraph ("把 `doc` / `docx` / `sheet` / `bitable`
导出到本地文件。这个 shortcut 内置有限轮询:") into the same blockquote so the content remains
one continuous blockquote (edit the lines around the blockquote marker to
eliminate the empty line).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b1a9a63-3f2c-43b6-a792-dc9c026cdb23

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad0b90 and a94697a.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_common_test.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_import.go
  • shortcuts/drive/drive_import_common.go
  • shortcuts/drive/drive_import_common_test.go
  • skills/lark-drive/references/lark-drive-export.md
  • skills/lark-drive/references/lark-drive-import.md
✅ Files skipped from review due to trivial changes (2)
  • shortcuts/drive/drive_import.go
  • shortcuts/drive/drive_export_common_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • skills/lark-drive/references/lark-drive-import.md
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_import_common_test.go

@liujinkun2025 liujinkun2025 force-pushed the feat/bitable-base-import-export branch from a94697a to 7bdf03b Compare April 22, 2026 06:54
Allow drive +export to request bitable snapshots with --file-extension base and write them with a .base suffix.

Allow drive +import to accept .base files for bitable only, enforce the 20 MB size limit, and document the new examples and constraints.

Add unit tests for validation and size-limit coverage.

Change-Id: Ia13f5013913812df5fc600c43f90918de4ca6b39
@liujinkun2025 liujinkun2025 force-pushed the feat/bitable-base-import-export branch from 7bdf03b to 16c9ed6 Compare April 22, 2026 09:44
@github-actions github-actions Bot added the domain/base PR touches the base domain label Apr 22, 2026
@fangshuyu-768 fangshuyu-768 merged commit 295f1d5 into main Apr 22, 2026
22 checks passed
@fangshuyu-768 fangshuyu-768 deleted the feat/bitable-base-import-export branch April 22, 2026 14:01
@liangshuo-1 liangshuo-1 mentioned this pull request Apr 23, 2026
3 tasks
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 domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants