Skip to content

feat(base): support record share link#466

Open
yballul-bytedance wants to merge 1 commit intomainfrom
feat/record-share-cli
Open

feat(base): support record share link#466
yballul-bytedance wants to merge 1 commit intomainfrom
feat/record-share-cli

Conversation

@yballul-bytedance
Copy link
Copy Markdown
Collaborator

@yballul-bytedance yballul-bytedance commented Apr 14, 2026

Change-Id: Ie78da99096cc1fc8a4671d8178176f4c587466ba

Summary

Add +record-share-link-create and +record-share-link-batch-create base shortcuts for generating share links for single or batch records.

Changes

  1. Add +record-share-link-create — generate share link for a single record

• Endpoint: POST /bases/:base_token/tables/:table_id/records/:record_id/share_links
• Flags: --base-token, --table-id, --record-id
• Returns the share link for the given record

  1. Add +record-share-link-batch-create — batch generate share links (max 100 per call)

• Endpoint: POST /bases/:base_token/tables/:table_id/records/share_links/batch
• Flags: --base-token, --table-id, --record-ids (string_slice type, comma-separated, max 100)
• Auto-deduplication + validation (empty input / over 100 records are rejected)
• Returns record_share_links map (key: record_id, value: share link)

  1. Add string_slice flag type and StrSlice() method in runner

• Leverages pflag's StringSlice, supporting both comma-separated and repeatable flag styles

  1. Add skill documentation

• lark-base-record-share-link-create.md
• lark-base-record-share-link-batch-create.md (with request/response JSON examples)
• Update lark-base-record.md index page

Test Plan

• Unit tests pass (shortcuts/base, shortcuts/common)
• Manual local verification confirms the lark base +record-share-link-* commands work as expected

Related Issues

None

Summary by CodeRabbit

Release Notes

  • New Features

    • Added record share link generation for individual records
    • Added batch record share link generation supporting up to 100 records per batch
    • Added string slice flag type support for CLI parameters
  • Documentation

    • Added documentation for record share link creation commands
    • Added reference guides for both single and batch share link operations

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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions github-actions bot added domain/base PR touches the base domain size/L Large or sensitive change across domains or core paths labels Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

This PR introduces two new record share-link commands (+record-share-link-create and +record-share-link-batch-create) to the base shortcuts system. Implementation includes validation logic, deduplication of record IDs, dry-run and execute functions, along with corresponding test and documentation updates. A new StrSlice() method is added to the runtime context to support string-slice flag types.

Changes

Cohort / File(s) Summary
Shortcut Definitions
shortcuts/base/record_share_link_create.go, shortcuts/base/record_share_link_batch_create.go
Added two new exported common.Shortcut variables: BaseRecordShareLinkCreate (single record) and BaseRecordShareLinkBatchCreate (batch with max 100 records). Both include required flags, scope declarations, validation, and execution wiring.
Shortcut Registration
shortcuts/base/shortcuts.go
Updated Shortcuts() function to include the two new shortcut definitions in the returned slice.
Implementation Logic
shortcuts/base/record_ops.go
Added validation (validateRecordShareBatch), deduplication (deduplicateRecordIDs), dry-run builders (dryRunRecordShare, dryRunRecordShareBatch), and execution functions (executeRecordShare, executeRecordShareBatch) for both single and batch record share-link operations.
Runtime Infrastructure
shortcuts/common/runner.go
Added StrSlice() method to RuntimeContext to retrieve string-slice flag values. Updated registerShortcutFlags() to recognize and bind "string_slice" flag type.
Tests
shortcuts/base/base_shortcuts_test.go
Updated TestShortcutsCatalog expected shortcuts list to include the two new record share-link commands.
Documentation
skills/lark-base/references/lark-base-record-share-link-create.md, skills/lark-base/references/lark-base-record-share-link-batch-create.md, skills/lark-base/references/lark-base-record.md
Added reference documentation for both new commands with CLI usage examples, HTTP API paths, required parameters, and constraints. Updated record index to include links to new command documentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

size/M

Suggested reviewers

  • zgz2048
  • zhaoleibd

Poem

🐰 With twitching whiskers bright and keen,
New share links grace the record scene!
From one to many, a batch's delight,
These links now hop through the base so tight! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 includes a comprehensive summary and detailed changes list, but does not follow the template structure with proper section formatting and leaves test plan items unchecked. Verify that all checklist items in the Test Plan section are completed and checked before merging. Ensure section formatting aligns with the repository template.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(base): support record share link' clearly and concisely describes the main change—adding record share link functionality to the base service.

✏️ 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/record-share-cli

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.

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_ops.go`:
- Around line 132-154: validateRecordShareBatch currently checks the raw
runtime.StrSlice length which can include empty entries (e.g. "--record-ids ,")
that are later removed by deduplicateRecordIDs; change validateRecordShareBatch
to use the normalized, deduplicated slice (call deduplicateRecordIDs or extract
the normalization logic) and validate that the resulting slice is non-empty and
does not exceed maxShareBatchSize, returning the same FlagErrorf messages but
using the normalized length; keep deduplicateRecordIDs as the normalizer that
trims empty strings and deduplicates entries so both validation and payload
construction use the same canonical list.
🪄 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: a87ab232-1201-49ce-95c2-0d7e8b727b2d

📥 Commits

Reviewing files that changed from the base of the PR and between 20761fa and ca1be84.

📒 Files selected for processing (6)
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/record_ops.go
  • shortcuts/base/record_share_batch_create.go
  • shortcuts/base/record_share_create.go
  • shortcuts/base/shortcuts.go
  • shortcuts/common/runner.go

Comment on lines +132 to +154
func validateRecordShareBatch(runtime *common.RuntimeContext) error {
recordIDs := runtime.StrSlice("record-ids")
if len(recordIDs) == 0 {
return common.FlagErrorf("--record-ids is required and must not be empty")
}
if len(recordIDs) > maxShareBatchSize {
return common.FlagErrorf("--record-ids exceeds maximum limit of %d (got %d)", maxShareBatchSize, len(recordIDs))
}
return nil
}

func deduplicateRecordIDs(runtime *common.RuntimeContext) []string {
raw := runtime.StrSlice("record-ids")
seen := make(map[string]bool, len(raw))
result := make([]string, 0, len(raw))
for _, id := range raw {
if id != "" && !seen[id] {
seen[id] = true
result = append(result, id)
}
}
return result
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Validate normalized record IDs, not raw slice length.

Line 133 checks the raw slice length, but Lines 143-153 later drop empty values. Inputs like --record-ids , can pass validation and still send an empty records payload.

Proposed fix
 func validateRecordShareBatch(runtime *common.RuntimeContext) error {
-	recordIDs := runtime.StrSlice("record-ids")
+	recordIDs := deduplicateRecordIDs(runtime)
 	if len(recordIDs) == 0 {
 		return common.FlagErrorf("--record-ids is required and must not be empty")
 	}
 	if len(recordIDs) > maxShareBatchSize {
 		return common.FlagErrorf("--record-ids exceeds maximum limit of %d (got %d)", maxShareBatchSize, len(recordIDs))
 	}
 	return nil
 }

 func deduplicateRecordIDs(runtime *common.RuntimeContext) []string {
 	raw := runtime.StrSlice("record-ids")
 	seen := make(map[string]bool, len(raw))
 	result := make([]string, 0, len(raw))
 	for _, id := range raw {
-		if id != "" && !seen[id] {
+		id = strings.TrimSpace(id)
+		if id != "" && !seen[id] {
 			seen[id] = true
 			result = append(result, id)
 		}
 	}
 	return result
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func validateRecordShareBatch(runtime *common.RuntimeContext) error {
recordIDs := runtime.StrSlice("record-ids")
if len(recordIDs) == 0 {
return common.FlagErrorf("--record-ids is required and must not be empty")
}
if len(recordIDs) > maxShareBatchSize {
return common.FlagErrorf("--record-ids exceeds maximum limit of %d (got %d)", maxShareBatchSize, len(recordIDs))
}
return nil
}
func deduplicateRecordIDs(runtime *common.RuntimeContext) []string {
raw := runtime.StrSlice("record-ids")
seen := make(map[string]bool, len(raw))
result := make([]string, 0, len(raw))
for _, id := range raw {
if id != "" && !seen[id] {
seen[id] = true
result = append(result, id)
}
}
return result
}
func validateRecordShareBatch(runtime *common.RuntimeContext) error {
recordIDs := deduplicateRecordIDs(runtime)
if len(recordIDs) == 0 {
return common.FlagErrorf("--record-ids is required and must not be empty")
}
if len(recordIDs) > maxShareBatchSize {
return common.FlagErrorf("--record-ids exceeds maximum limit of %d (got %d)", maxShareBatchSize, len(recordIDs))
}
return nil
}
func deduplicateRecordIDs(runtime *common.RuntimeContext) []string {
raw := runtime.StrSlice("record-ids")
seen := make(map[string]bool, len(raw))
result := make([]string, 0, len(raw))
for _, id := range raw {
id = strings.TrimSpace(id)
if id != "" && !seen[id] {
seen[id] = true
result = append(result, id)
}
}
return result
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/base/record_ops.go` around lines 132 - 154,
validateRecordShareBatch currently checks the raw runtime.StrSlice length which
can include empty entries (e.g. "--record-ids ,") that are later removed by
deduplicateRecordIDs; change validateRecordShareBatch to use the normalized,
deduplicated slice (call deduplicateRecordIDs or extract the normalization
logic) and validate that the resulting slice is non-empty and does not exceed
maxShareBatchSize, returning the same FlagErrorf messages but using the
normalized length; keep deduplicateRecordIDs as the normalizer that trims empty
strings and deduplicates entries so both validation and payload construction use
the same canonical list.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/record-share-cli -y -g

Change-Id: Ie78da99096cc1fc8a4671d8178176f4c587466ba
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/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant