Skip to content

feat: configure initial base table schema#1377

Merged
zgz2048 merged 2 commits into
larksuite:mainfrom
zgz2048:codex/base-create-initial-table-schema
Jun 10, 2026
Merged

feat: configure initial base table schema#1377
zgz2048 merged 2 commits into
larksuite:mainfrom
zgz2048:codex/base-create-initial-table-schema

Conversation

@zgz2048

@zgz2048 zgz2048 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add +base-create --fields support for configuring the initial table schema during Base creation.
  • Add --table-name support for the initial table name, including compatibility behavior for table-name-only rename and fields-only default table name Table 1.
  • Refactor +table-create --fields to send fields directly in the create-table request body, matching OpenAPI support.
  • Update Base skill/help guidance to strongly recommend configuring the initial table name and schema together and to read the field JSON schema before using --fields.

Validation

  • make unit-test
  • go test ./tests/cli_e2e/base -run 'TestBaseCreateDryRun'\n- gofmt -l .\n- go vet ./...\n- go mod tidy && git diff --exit-code -- go.mod go.sum\n- Manual dry-run regression for four +base-create parameter combinations:\n - no --table-name, no --fields: only POST /bases\n - --table-name only: POST /bases, GET /tables, PATCH /tables/:default_table_id\n - --fields only: POST /bases, GET /tables, POST /tables with name: Table 1, DELETE default table\n - both --table-name and --fields: POST /bases, GET /tables, POST /tables with passed table name and fields, DELETE default table\n\n## Known Check Failure\n\n- go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main currently fails on existing unrelated depguard/forbidigo findings in files not touched by this PR, including cmd/auth/qrcode.go, cmd/config/*, shortcuts/event/pipeline.go, shortcuts/mail/*, and shortcuts/minutes/minutes_download.go.\n

Summary by CodeRabbit

  • New Features

    • Added --fields and --table-name to customize the initial table when creating a base; creation flow supports creating a custom first table, renaming the default table, or using default name.
  • Documentation

    • Updated tips and examples to include recommended JSON field schema guidance and an explicit example using both flags.
  • Tests

    • Added extensive dry-run, unit, and e2e tests covering fields/table-name combinations and output behavior.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0695609f-cd5e-49da-bc77-9b398cbdf3e7

📥 Commits

Reviewing files that changed from the base of the PR and between 44910f8 and e54411e.

📒 Files selected for processing (2)
  • shortcuts/base/base_create.go
  • shortcuts/base/base_shortcuts_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/base_create.go

📝 Walkthrough

Walkthrough

Adds --fields and --table-name to +base-create, refactors table creation to include fields in the create payload, and implements conditional dry-run/execution flows to either replace (with --fields) or rename (with --table-name only) the platform default first table.

Changes

Custom initial table schema for base creation

Layer / File(s) Summary
Flag definition and validation
shortcuts/base/base_create.go, shortcuts/base/base_shortcuts_test.go
The BaseBaseCreate shortcut declares --fields (JSON array describing first table schema) and --table-name (custom table name) flags, expands User/Bot scopes, updates Tips with a recommended usage example and guidance to follow the field JSON shape, and wires Validate to validateBaseCreate. Tests verify help text, validation, and scope lists.
Table creation request body refactoring
shortcuts/base/table_ops.go
Table creation now builds POST bodies via buildTableCreateBody and dryRunTableCreateBody, parsing and attaching --fields only when provided; dry-run substitutes a sentinel on parse errors. Execution uses the API response fields instead of issuing per-field follow-ups.
Dry-run modeling of post-create table operations
shortcuts/base/base_ops.go, shortcuts/base/base_dryrun_ops_test.go, tests/cli_e2e/base/base_create_dryrun_test.go
dryRunBaseCreate models different post-create sequences: with --fields it creates a custom table then deletes the default; with --table-name only it patches (renames) the default table. Unit and e2e tests assert the expected API call sequences, methods, and request payloads for each scenario.
Execution of table replacement or rename
shortcuts/base/base_ops.go, shortcuts/base/base_execute_test.go
executeBaseCreate branches on flags: --fields calls replaceBaseDefaultTable to create the custom table (using built payloads), extract fields, wait a configurable delay, and delete the default table; --table-name only calls renameBaseDefaultTable to PATCH the default table name. Helpers extract base/table tokens and resolve default table IDs; execution tests validate outputs and captured request bodies.
Documentation and user guidance updates
shortcuts/base/table_create.go, skills/lark-base/SKILL.md
+table-create Tips updated to mark the first --fields item as the primary field. SKILL.md adds guidance recommending +base-create with --table-name and --fields defined upfront and points to the field JSON reference; it clarifies default behavior when both flags are omitted.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • kongenpei

Poem

🐰 A table takes shape from the CLI's command,
Fields lined up neat as a gardener’s band,
The default steps aside with a soft little hop,
Custom schema blooms, and the old table stops,
Hooray — the rabbit claps, and prints the base id on top!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 'feat: configure initial base table schema' clearly and concisely summarizes the main feature addition—enabling schema configuration for the initial table when creating a Base.
Description check ✅ Passed The PR description includes all required template sections: Summary (motivation and scope), Changes (main changes listed), Test Plan (validation methods described), and Related Issues (stated as None).
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 unit tests (beta)
  • Create PR with unit tests

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/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.54967% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.95%. Comparing base (cc416a4) to head (e54411e).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/base/base_ops.go 66.66% 21 Missing and 17 partials ⚠️
shortcuts/base/table_ops.go 67.64% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1377      +/-   ##
==========================================
+ Coverage   71.47%   71.95%   +0.47%     
==========================================
  Files         688      699      +11     
  Lines       65483    66285     +802     
==========================================
+ Hits        46807    47695     +888     
+ Misses      15031    14883     -148     
- Partials     3645     3707      +62     

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

@kongenpei

Copy link
Copy Markdown
Collaborator

One required fix before merge: +base-create now has execution paths that call table APIs, but its declared scopes still only include base:app:create (plus docs:permission.member:create for bot mode).

When --fields is used, the command can call:

  • GET /tables -> needs base:table:read
  • POST /tables -> needs base:table:create
  • DELETE /tables/:id -> needs base:table:delete

When only --table-name is used, it can call:

  • GET /tables -> needs base:table:read
  • PATCH /tables/:id -> needs base:table:update

Because UserScopes / BotScopes override Scopes, the preflight check will not surface these missing permissions. A caller can successfully create the Base and then fail during the follow-up table operation, leaving a partially configured Base. Please add the required scope declarations or a path-specific preflight so these modes fail fast before creating the Base.

Verified locally:

  • go test ./shortcuts/base -run 'TestBase(WorkspaceExecuteCreate|TableExecuteCreate|CreateValidate|DryRunBaseOps|DryRunTableOps|JSONExamplesLiveInFlagDescriptions)'
  • make build
  • go test ./tests/cli_e2e/base -run 'TestBaseCreateDryRun'

@zgz2048
zgz2048 marked this pull request as ready for review June 10, 2026 07:27
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add zgz2048/cli#codex/base-create-initial-table-schema -y -g

@zgz2048

zgz2048 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

@kongenpei fixed in e54411ea.

+base-create now declares the follow-up table operation scopes in both UserScopes and BotScopes:

  • base:table:read
  • base:table:create
  • base:table:update
  • base:table:delete

I also added TestBaseCreateScopesCoverFollowUpTableOperations so these scopes stay covered.

Validated with:

  • go test ./shortcuts/base -run 'TestBase(WorkspaceExecuteCreate|TableExecuteCreate|CreateValidate|DryRunBaseOps|DryRunTableOps|JSONExamplesLiveInFlagDescriptions|CreateScopesCoverFollowUpTableOperations|CreateTipsGuideFieldSchema)'
  • make build
  • go test ./tests/cli_e2e/base -run 'TestBaseCreateDryRun'
  • git diff --check

@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

🤖 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_create.go`:
- Around line 24-25: The command now performs table API calls when
--fields/--table-name are provided but the declared UserScopes and BotScopes
(symbols: UserScopes, BotScopes) only include base create permissions; update
those scope lists to also include "base:table:read", "base:table:create",
"base:table:update", and "base:table:delete" so preflight validates the actual
permissions needed, or alternatively implement a path-aware preflight check in
the base-create flow that inspects whether --fields/--table-name were passed and
validates those additional table scopes before calling CreateBase.

In `@shortcuts/base/base_ops.go`:
- Around line 37-68: The dryRunBaseCreate flow can trigger table APIs but the
shortcut's declared UserScopes/BotScopes (see base_create.go shortcut
definition) only include base:app:create; add the missing table scopes to avoid
post-create failures by expanding the shortcut's UserScopes and BotScopes to
include base:table:read, base:table:create, base:table:delete, and
base:table:update (alternatively implement path-specific scope addition when
runtime flags indicate --fields or --table-name), ensuring the shortcut
declaration (in the same place as the existing base:app:create entries
referenced by base_create.go) is updated accordingly.
🪄 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: 7a58c863-2d0b-44bd-9d52-4ff2310dbd93

📥 Commits

Reviewing files that changed from the base of the PR and between b07be60 and 44910f8.

📒 Files selected for processing (9)
  • shortcuts/base/base_create.go
  • shortcuts/base/base_dryrun_ops_test.go
  • shortcuts/base/base_execute_test.go
  • shortcuts/base/base_ops.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/table_create.go
  • shortcuts/base/table_ops.go
  • skills/lark-base/SKILL.md
  • tests/cli_e2e/base/base_create_dryrun_test.go

Comment thread shortcuts/base/base_create.go
Comment thread shortcuts/base/base_ops.go
@zgz2048
zgz2048 merged commit 077b5e7 into larksuite:main Jun 10, 2026
19 checks passed
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