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

Summary by CodeRabbit

  • New Features

    • Add single-record share link command (+record-share-link-create).
    • Add batch share link command (+record-share-link-batch-create) with a 100-record cap, input deduplication, and validation (rejects empty input).
  • Documentation

    • Added user guides and examples for single and batch record share link commands, including CLI usage, request behavior, and return/partial-failure semantics.

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

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 Base shortcuts to generate record share links (single and batch up to 100), implements validation/dry-run/execute handlers, adds a string-slice flag type to runtime, updates the shortcuts catalog and test, and includes user-facing docs for both commands.

Changes

Cohort / File(s) Summary
Core implementation
shortcuts/base/record_ops.go
Added single and batch record share-link handlers: dry-run builders, executors calling Base v3 endpoints, batch input deduplication, and batch-size validation (max 100).
Shortcut definitions & registration
shortcuts/base/record_share_link_create.go, shortcuts/base/record_share_link_batch_create.go, shortcuts/base/shortcuts.go
New +record-share-link-create and +record-share-link-batch-create shortcut definitions and registration in the Shortcuts() catalog immediately after batch-update.
Runtime flags
shortcuts/common/runner.go
Added RuntimeContext.StrSlice(name string) []string and support for the "string_slice" flag type (comma-separated or repeatable string lists).
Tests
shortcuts/base/base_shortcuts_test.go
Updated expected shortcut ordering to include the two new share-link commands in the catalog assertions.
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 usage and API docs for single and batch share-link commands; updated record reference navigation to include new entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • zgz2048

Poem

🐰 I dug a tunnel through the code,
I found a path where links can go.
One by one or in a crowd,
Up to a hundred — hop aloud!
Share the records — watch them flow ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(base): support record share link' is partially related to the changeset but overly broad, lacking specificity about the dual nature of the feature (single + batch operations).
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all required template sections: Summary, Changes, Test Plan, and Related Issues with clear details about implementation and testing.

✏️ 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/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

@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@3514ee5f97b48adc0d9ad815fcaef847a6867ee2

🧩 Skill update

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

@yballul-bytedance yballul-bytedance force-pushed the feat/record-share-cli branch 2 times, most recently from f47e987 to e221e6f Compare April 15, 2026 04:01
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: 4

♻️ Duplicate comments (1)
shortcuts/base/record_ops.go (1)

132-154: ⚠️ Potential issue | 🟠 Major

Validate the canonical record-ids list, not the raw slice.

validateRecordShareBatch checks runtime.StrSlice("record-ids"), but executeRecordShareBatch later drops empty entries and deduplicates them. Inputs like --record-ids , can still pass validation and then send an empty record_ids payload, and CSV input like rec1, rec2 will preserve the leading space on the second ID. Reuse the normalized list for validation and trim each element inside deduplicateRecordIDs.

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))
@@
 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
 }

Also add strings to the import block.

🤖 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 validates the raw
runtime.StrSlice("record-ids") instead of the normalized list; change
validateRecordShareBatch to call deduplicateRecordIDs (or otherwise normalize:
trim each entry and drop empties) and validate the resulting canonical slice
(check length >0 and <= maxShareBatchSize). Update deduplicateRecordIDs to trim
spaces from each id (using strings.TrimSpace), ignore empty strings after
trimming, and deduplicate as before. Add "strings" to the import block so
TrimSpace is available.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lark-env.sh`:
- Around line 235-248: The trap for cleaning up tmp_js is currently installed
unconditionally (trap 'rm -f "$tmp_js"' EXIT HUP INT TERM) before checking
is_sourced, which alters the parent shell when this script is sourced; move the
trap installation so it is only set after the is_sourced check fails (i.e.,
inside the non-sourced execution path that proceeds to run "$wcmd" add ...), and
ensure any early-return path that applies when sourced does not rely on the trap
(clean tmp_js explicitly or avoid creating the temp file when sourced);
reference tmp_js, write_rule_js, trap, is_sourced and the block that runs
"$wcmd" add to locate where to adjust placement and cleanup logic.
- Around line 34-36: The fail() helper currently returns but callers don't
propagate its non-zero status; update the call sites (the case branches that
call fail, the callers around build_rules() and other helpers) to explicitly
propagate failures by checking return values (e.g., call helpers as "if !
build_rules ...; then return 1; fi" or append "|| return 1" after helper calls)
and avoid swallowing errors in command substitution—do not assign
rules="$(build_rules ...)" directly without first verifying success; also ensure
the top-level flow (main or caller) checks helper return codes or enable
script-wide errexit semantics so a helper failure aborts the sourced script.

In `@shortcuts/base/record_ops.go`:
- Around line 115-120: The dry-run payload in dryRunRecordShareBatch is using
the wrong key ("records") so it does not match the real request which sends
{"record_ids": ...}; update dryRunRecordShareBatch to build the body with the
"record_ids" key (using deduplicateRecordIDs(runtime)) and keep the rest of the
request unchanged so the output of the dry-run matches the actual POST to
/open-apis/base/v3/bases/:base_token/tables/:table_id/records/share_links/batch.

In `@skills/lark-base/references/lark-base-record-share-link-create.md`:
- Around line 28-30: The fenced code block containing the HTTP endpoint "POST
/open-apis/base/v3/bases/:base_token/tables/:table_id/records/:record_id/share_links"
is missing a language tag and triggers MD040; update that fenced block to
include the language identifier (e.g., add "http" after the opening backticks)
so the block becomes a language-specific code fence and satisfies markdownlint.

---

Duplicate comments:
In `@shortcuts/base/record_ops.go`:
- Around line 132-154: validateRecordShareBatch currently validates the raw
runtime.StrSlice("record-ids") instead of the normalized list; change
validateRecordShareBatch to call deduplicateRecordIDs (or otherwise normalize:
trim each entry and drop empties) and validate the resulting canonical slice
(check length >0 and <= maxShareBatchSize). Update deduplicateRecordIDs to trim
spaces from each id (using strings.TrimSpace), ignore empty strings after
trimming, and deduplicate as before. Add "strings" to the import block so
TrimSpace is available.
🪄 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: 96ab410a-bfe3-4b65-ae44-9f0392f54791

📥 Commits

Reviewing files that changed from the base of the PR and between f47e987 and e221e6f.

📒 Files selected for processing (10)
  • lark-env.sh
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/record_ops.go
  • shortcuts/base/record_share_link_batch_create.go
  • shortcuts/base/record_share_link_create.go
  • shortcuts/base/shortcuts.go
  • shortcuts/common/runner.go
  • skills/lark-base/references/lark-base-record-share-link-batch-create.md
  • skills/lark-base/references/lark-base-record-share-link-create.md
  • skills/lark-base/references/lark-base-record.md
✅ Files skipped from review due to trivial changes (3)
  • shortcuts/base/shortcuts.go
  • skills/lark-base/references/lark-base-record.md
  • skills/lark-base/references/lark-base-record-share-link-batch-create.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/record_share_link_create.go

@yballul-bytedance yballul-bytedance force-pushed the feat/record-share-cli branch 2 times, most recently from 27d5c28 to cd3b713 Compare April 15, 2026 08:10
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