Skip to content

fix(sheets): support file input for values#1193

Open
ccchenhuohuo wants to merge 1 commit into
larksuite:mainfrom
ccchenhuohuo:codex/sheets-values-file-input
Open

fix(sheets): support file input for values#1193
ccchenhuohuo wants to merge 1 commit into
larksuite:mainfrom
ccchenhuohuo:codex/sheets-values-file-input

Conversation

@ccchenhuohuo
Copy link
Copy Markdown

@ccchenhuohuo ccchenhuohuo commented Jun 1, 2026

Summary

  • Allow sheets +write --values and sheets +append --values to use existing shortcut input conventions: @file and - for stdin.
  • Update help text so large 2D JSON payloads can be passed without shell quoting fragile inline JSON.
  • Add dry-run regression tests covering file input and stdin with Chinese cell values.

Root cause

sheets +write/+append parsed the raw --values flag directly with json.Unmarshal, but the flag did not opt into the shortcut framework input resolver. As a result, --values @values.json was parsed literally as JSON and failed with --values invalid JSON, must be a 2D array.

Reproduction

Before the fix, lark-cli sheets +write --spreadsheet-token sht_test --range sheet1!A1 --values @./values.json --dry-run failed with --values invalid JSON, must be a 2D array. With this branch, the same command resolves the file and includes the loaded 2D array in the dry-run body.

Validation

  • go test ./shortcuts/sheets -run "TestSheetWriteDryRunAcceptsValuesFileInput|TestSheetAppendDryRunAcceptsValuesStdinInput|TestCellDataValidateRejectsNon2DValues" -count=1
  • go test ./shortcuts/sheets -count=1
  • go build -o /tmp/lark-cli-sheets-values .
  • Manual dry-run with built binary for --values @file and --values -

Notes

go test ./... was also run. It failed in unrelated environment-dependent suites: schema tests could not find generated registry services such as im; e2e tests required a repo-root ./lark-cli binary and live Feishu app scopes such as calendar:calendar:read / space:folder:create.

Summary by CodeRabbit

  • New Features
    • Sheet write and append operations now support flexible data input methods for the values parameter. Users can provide JSON directly, load data from files (using @file), or read from standard input (using -). This enables more convenient ways to supply large or dynamically generated datasets to spreadsheet operations.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 1, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

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: 8ae73c6b-b1ad-4a44-939c-ac1d1cd0c59f

📥 Commits

Reviewing files that changed from the base of the PR and between 99e314f and d7adc9c.

📒 Files selected for processing (2)
  • shortcuts/sheets/lark_sheets_cell_data.go
  • shortcuts/sheets/lark_sheets_sheet_ranges_test.go

📝 Walkthrough

Walkthrough

The PR extends the values flag for sheets +write and sheets +append commands to accept 2D array JSON input from file paths (via @file) and stdin (via -), in addition to inline JSON, with corresponding dry-run tests to validate the new input sources.

Changes

Sheet Values Flag Input Sources

Layer / File(s) Summary
Values flag metadata updates
shortcuts/sheets/lark_sheets_cell_data.go
SheetWrite and SheetAppend update their values flag Input configuration to []string{common.File, common.Stdin} and update the flag description to indicate support for @file and stdin sources.
Dry-run test coverage for values input
shortcuts/sheets/lark_sheets_sheet_ranges_test.go
New test cases TestSheetWriteDryRunAcceptsValuesFileInput and TestSheetAppendDryRunAcceptsValuesStdinInput verify that values can be loaded from files and stdin, and assert the dry-run output contains the normalized range and expected cell values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • fangshuyu-768

Poem

📊 A humble sheet now speaks in fuller voice,
From files and streams, it has more choice—
No longer bound to typed-in JSON strings,
The values flag now spreads its mighty wings! 🐰✨

🚥 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 clearly summarizes the main change: adding file input support for the values flag in sheets commands.
Description check ✅ Passed The description is comprehensive and follows the template with all major sections: Summary, Changes, Test Plan, Related Issues, Root cause, Reproduction, and Validation steps.
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/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Jun 1, 2026
@ccchenhuohuo
Copy link
Copy Markdown
Author

@coderabbitai review

@ccchenhuohuo ccchenhuohuo marked this pull request as ready for review June 1, 2026 03:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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