Skip to content

fix(sheets): mark +delete-dimension high-risk-write#1533

Open
hehanlin1996 wants to merge 2 commits into
larksuite:mainfrom
hehanlin1996:fix/sheets-delete-dimension-high-risk
Open

fix(sheets): mark +delete-dimension high-risk-write#1533
hehanlin1996 wants to merge 2 commits into
larksuite:mainfrom
hehanlin1996:fix/sheets-delete-dimension-high-risk

Conversation

@hehanlin1996

@hehanlin1996 hehanlin1996 commented Jun 22, 2026

Copy link
Copy Markdown

Summary

sheets +delete-dimension deletes entire rows/columns (irreversible) but was annotated Risk: "write", so it never triggered the high-risk confirmation gate. Its modern replacement +dim-delete and the sibling +delete-sheet are both high-risk-write. This aligns the deprecated alias with them.

Changes

  • SheetDeleteDimension.Risk: "write""high-risk-write", so without --yes it returns a structured confirmation_required error (exit 10); --yes executes; --dry-run still previews without confirmation.
  • Added a metadata test locking the risk level (regression guard).
  • Added gate-behavior tests: without --yes blocked + API not called / with --yes executes / --dry-run bypasses.
  • Updated the existing execute tests to pass --yes under the gate.

Test Plan

  • Unit tests pass: go test ./shortcuts/sheets/...
  • Manual local verification confirms the lark-cli sheets +delete-dimension flow works as expected:
    • --help shows Risk: high-risk-write and --yes
    • without --yes → exit 10, confirmation_required, no network call
    • --dry-run → previews the DELETE, no --yes needed
    • --yes → passes the gate and reaches the API

Related Issues

Summary by CodeRabbit

  • New Features
    • The +delete-dimension command now uses a higher-risk safety level and requires an explicit --yes confirmation to proceed, since row/column deletion is irreversible.
    • Use --dry-run to preview the DELETE request and response output without triggering the confirmation gate.
  • Tests
    • Updated and added coverage to verify the new risk level, blocking behavior without --yes, successful execution with --yes, and confirmation bypass during --dry-run.

@coderabbitai

coderabbitai Bot commented Jun 22, 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: e004c1b3-9b33-4238-9c9d-a7ea63d155b1

📥 Commits

Reviewing files that changed from the base of the PR and between fe84b95 and 68a4a85.

📒 Files selected for processing (2)
  • shortcuts/sheets/backward/lark_sheets_row_column_management.go
  • shortcuts/sheets/backward/lark_sheets_sheet_dimension_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/sheets/backward/lark_sheets_row_column_management.go
  • shortcuts/sheets/backward/lark_sheets_sheet_dimension_test.go

📝 Walkthrough

Walkthrough

SheetDeleteDimension.Risk is changed from "write" to "high-risk-write" with an explanatory inline comment. Existing tests for this command are updated to supply --yes, and four new tests are added to cover the confirmation gate: risk tier assertion, blocked execution without --yes, allowed execution with --yes, and dry-run bypass.

Changes

SheetDeleteDimension confirmation gate

Layer / File(s) Summary
Risk field promotion
shortcuts/sheets/backward/lark_sheets_row_column_management.go
SheetDeleteDimension.Risk changed from "write" to "high-risk-write"; inline comment added explaining the irreversibility and --yes gate.
Test updates and new gate tests
shortcuts/sheets/backward/lark_sheets_sheet_dimension_test.go
net/http and errs imports added; three existing tests updated to pass --yes; four new tests added asserting "high-risk-write" tier, rejection without --yes, acceptance with --yes, and dry-run bypass.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • larksuite/cli#413: Introduced the +delete-dimension shortcut that this PR now tightens with a high-risk-write confirmation gate.
  • larksuite/cli#633: Implements the high-risk-write risk tiering and structured confirmation behavior that +delete-dimension now adopts.

Suggested reviewers

  • fangshuyu-768
  • liangshuo-1

Poem

🐇 Hop hop, I guard the rows and cols with care,
A --yes you must type before deleting there.
No sneaky erasure without a clear nod,
high-risk-write stands firm, it's the safety squad.
Your data is safer — this bunny approves! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% 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 accurately describes the main change: marking +delete-dimension as high-risk-write.
Description check ✅ Passed The description covers all required template sections: Summary explains the issue and alignment, Changes lists implementation details, Test Plan confirms verification, and Related Issues links issue #1532.
Linked Issues check ✅ Passed The PR fully addresses issue #1532 by marking SheetDeleteDimension.Risk as high-risk-write, adding risk-level and gate-behavior tests, and ensuring --yes is required for execution while --dry-run bypasses confirmation.
Out of Scope Changes check ✅ Passed All changes directly support the objective: risk annotation update, metadata test for regression protection, gate-behavior tests, and test updates to pass --yes. No unrelated modifications.

✏️ 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 the domain/ccm PR touches the ccm domain label Jun 22, 2026
@CLAassistant

CLAassistant commented Jun 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jun 22, 2026

@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: 1

🤖 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/sheets/backward/lark_sheets_sheet_dimension_test.go`:
- Around line 980-982: The error validation at lines 980-982 only checks if the
error is non-nil but does not validate typed error metadata, allowing
regressions in error types to go undetected. Replace the nil check with proper
typed error assertion using errs.ProblemOf to validate the error category and
subtype metadata, and assert the error cause chain where applicable. Apply this
same pattern to the additional locations mentioned at lines 1018-1020 as well.
🪄 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: db73caeb-d6ef-46dc-9cff-58bb285b31bb

📥 Commits

Reviewing files that changed from the base of the PR and between 824aa9e and d754958.

📒 Files selected for processing (2)
  • shortcuts/sheets/backward/lark_sheets_row_column_management.go
  • shortcuts/sheets/backward/lark_sheets_sheet_dimension_test.go

Comment thread shortcuts/sheets/backward/lark_sheets_sheet_dimension_test.go Outdated
@hehanlin1996

Copy link
Copy Markdown
Author

Thanks @coderabbitai — addressed in fe84b95. The two error-path tests now assert typed metadata via errs.ProblemOf instead of nil/substring checks:

  • confirmation path → Category=confirmation / Subtype=confirmation_required
  • API-error path → Category=api / Code=90001

The success and --dry-run paths already assert behavior (executed/preview) so they're left as-is.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh api repos/larksuite/cli/pulls/1533/commits --jq '.[].sha' | head -5
gh api repos/larksuite/cli/commits/fe84b955 --jq '.files[] | select(.filename | contains("dimension_test")) | {filename: .filename, patch: .patch}'

Length of output: 2060



@hehanlin1996 Confirmed — commit fe84b95 matches the description. Both error paths now use errs.ProblemOf for typed assertions:

  • TestSheetDeleteDimensionWithoutYesRequiresConfirmationCategory=CategoryConfirmation / Subtype=SubtypeConfirmationRequired
  • TestSheetDeleteDimensionExecuteAPIErrorCategory=CategoryAPI / Code=90001

The improvement over nil/substring checks is meaningful — these will catch regressions in both the error type and its structured metadata, not just the message text.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@hehanlin1996

Copy link
Copy Markdown
Author

recheck

hehanlin1996 and others added 2 commits June 22, 2026 17:27
Deleting rows/columns is an irreversible structural change, but the
deprecated +delete-dimension alias was annotated Risk: "write" and so
never triggered the confirmation gate. Its modern replacement +dim-delete
and the sibling +delete-sheet are both high-risk-write.

Align +delete-dimension with them: without --yes it now returns a
structured confirmation_required error (exit 10); --yes executes; --dry-run
still previews without confirmation.

- Lock the risk level with a metadata test.
- Add gate-behavior tests (without --yes blocked / with --yes executes /
  --dry-run bypasses), and pass --yes in the existing execute tests.

Closes larksuite#1532

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…aths

Address CodeRabbit review: error-path tests must assert typed metadata via
errs.ProblemOf, not nil/message-substring checks.

- confirmation path: assert Category=confirmation / Subtype=confirmation_required
- API-error path: assert Category=api / Code=90001

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hehanlin1996 hehanlin1996 force-pushed the fix/sheets-delete-dimension-high-risk branch from fe84b95 to 68a4a85 Compare June 22, 2026 09:27
@hehanlin1996

Copy link
Copy Markdown
Author

recheck

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.

sheets +delete-dimension is missing the high-risk-write confirmation gate

2 participants