fix(sheets): allow +pivot-create to omit both sheet selectors#1130
Merged
zhengzhijiej-tech merged 1 commit intoMay 27, 2026
Conversation
manage_pivot_table_object treats sheet_id / sheet_name as the placement target — when both are absent, handleCreate() auto-creates a new sub-sheet to host the pivot table. The CLI's flag schema didn't reflect this: - Exposed a third flag --target-sheet-id that mapped to the same wire field as --sheet-id, leaving the caller unsure which one to use - --sheet-id / --sheet-name had "XOR with the other" descriptions that read like "operation context", so callers (especially LLM tool callers) felt obligated to set one — frequently the source sheet — which silently disabled the backend's auto-create guardrail and dropped the pivot at A1, overlapping the source data Wire change (synced from sheet-skill-spec): drop the duplicate --target-sheet-id flag; rewrite --sheet-id / --sheet-name descriptions to make the placement-target semantics explicit and call out that omitting both is the recommended path. Implementation change (this PR): add an at-most-one sheet-selector helper and let object create-shortcuts opt into it. - helpers.go: new optionalSheetSelector (both empty allowed; both set still rejected; control-char validation unchanged). requireSheetSelector is untouched — every existing caller keeps the exactly-one contract. - lark_sheet_object_crud.go: objectCRUDSpec gains allowEmptySheetSelectorOnCreate; objectCreateInput dispatches to optionalSheetSelector when it's set. Only pivotSpec opts in; chart / cond-format / sparkline / filter-view / float-image keep the existing require semantics. DryRun and Execute switch to direct flag extraction (same pattern Validate already used) so the XOR check happens in exactly one place (the builder). - pivotSpec: drop the enhanceCreateInput branch that read the now-removed --target-sheet-id flag. - Tests: TestPivotCreate_SheetSelectorSemantics covers both-empty / both-set / single-set; TestObjectCreate_RequiresSheetSelector regresses chart / cond-format / sparkline / filter-view to lock the scope of the relaxation.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
vinnyxiong
approved these changes
May 27, 2026
e85afd6
into
larksuite:feat/lark-sheets-refactor
3 checks passed
zhengzhijiej-tech
added a commit
to zhengzhijiej-tech/cli
that referenced
this pull request
May 27, 2026
Companion sync from sheet-skill-spec — the canonical reference rewrites +pivot-create's "5 placement-related flags" rundown into a clearer "4 placement-related flags" form (--target-sheet-id was already removed in larksuite#1130, this updates the prose accordingly), and clarifies that --sheet-id / --sheet-name on +pivot-create are the *placement* sheet (not the source-data sheet), with omit-both as the strongly-recommended default. Also picks up a base-side --target-position description tweak that dropped the now-stale "与 --target-sheet-id 配套" reference. No CLI surface change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
manage_pivot_table_objecttreatssheet_id/sheet_nameas the placement target — when both are absent,handleCreate()auto-creates a new sub-sheet to host the pivot table. The CLI's flag schema didn't reflect that:--target-sheet-idduplicated the same wire field as--sheet-id, leaving callers unsure which one to use.--sheet-id/--sheet-namehad "XOR with the other" descriptions that read like "operation context", so callers (especially LLM tool callers) felt obligated to set one. Frequently that ended up being the source sheet, which silently disabled the backend's auto-create guardrail and dropped the pivot at A1 — overlapping the source data with#REF!.This PR aligns the CLI to the backend's actual contract.
Changes
Wire schema (synced from
sheet-skill-speccompanion change):--target-sheet-idflag from+pivot-create.--sheet-id/--sheet-namedescriptions to make placement-target semantics explicit, and call out that omitting both is the recommended path.Implementation:
helpers.go: newoptionalSheetSelector("at most one" — both empty allowed; both set still rejected).requireSheetSelectoris untouched, so every existing caller keeps the exactly-one contract.lark_sheet_object_crud.go:objectCRUDSpecgainsallowEmptySheetSelectorOnCreate;objectCreateInputdispatches tooptionalSheetSelectorwhen set. OnlypivotSpecopts in; chart / cond-format / sparkline / filter-view / float-image continue to require a sheet selector.pivotSpec.enhanceCreateInput: remove the branch that read the now-removed--target-sheet-idflag.Test plan
TestPivotCreate_SheetSelectorSemanticscovers both-empty (accepted), both-set (rejected with "mutually exclusive"), and single-set (accepted) paths.TestObjectCreate_RequiresSheetSelectorregresses chart / cond-format / sparkline / filter-view to confirm the relaxation is scoped to pivot only.TestObjectCRUDShortcuts_DryRunupdated: removed--target-sheet-idfrom the pivot case, added a both-empty case asserting the input has nosheet_id/sheet_name.go build ./... && go test ./shortcuts/sheets/...pass.