Skip to content

fix: align drive add-comment text validation with OpenAPI limit#613

Open
wittam-01 wants to merge 1 commit intomainfrom
fix/drive-add-comment-openapi-length-limit
Open

fix: align drive add-comment text validation with OpenAPI limit#613
wittam-01 wants to merge 1 commit intomainfrom
fix/drive-add-comment-openapi-length-limit

Conversation

@wittam-01
Copy link
Copy Markdown
Collaborator

@wittam-01 wittam-01 commented Apr 22, 2026

Summary

This change aligns drive +add-comment validation with the underlying OpenAPI behavior. The CLI previously rejected any single text reply element longer than 1000 characters, which was stricter than the backend and blocked valid requests.

Changes

  • Replace the per-element 1000-character text limit in drive +add-comment with a 10000-character aggregate limit across all caller-provided text elements.
  • Keep the validation conservative on the CLI side and leave mention/link expansion length checks to the backend.

Test Plan

  • Targeted unit tests pass: go test ./shortcuts/drive -run 'TestParseCommentReplyElements'
  • Local build passes: make build
  • Full make unit-test
  • Manual local verification confirms the lark xxx command works as expected

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes
    • Updated comment text validation to enforce a combined 10,000 character limit across all text elements instead of individual limits, with clearer error messaging.

Change-Id: Iab4ceab7c84a7dc0df61825c1835d1a8aca3372f
@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 Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.97%. Comparing base (543a836) to head (72dacaf).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
+ Coverage   59.94%   59.97%   +0.02%     
==========================================
  Files         405      405              
  Lines       42673    42712      +39     
==========================================
+ Hits        25580    25616      +36     
- Misses      15084    15086       +2     
- Partials     2009     2010       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

Modified Google Drive comment validation to enforce a cumulative 10,000 character limit across all text elements, replacing the previous per-element restriction. Updated validation logic to track aggregate text rune counts and adjusted error messaging accordingly.

Changes

Cohort / File(s) Summary
Comment Validation Logic
shortcuts/drive/drive_add_comment.go
Added maxCommentTextRuneCount constant set to 10,000. Modified parseCommentReplyElements to accumulate UTF-8 rune counts across all text elements and validate against the total limit instead of individual element limits. Updated error messaging to reflect aggregate text validation.
Validation Test Coverage
shortcuts/drive/drive_add_comment_test.go
Added TestParseCommentReplyElementsAllowsTextTotalAtOpenAPILimit to verify acceptance of multiple text elements totaling exactly 10,000 characters. Extended TestParseCommentReplyElementsInvalid with test case confirming rejection when cumulative text exceeds the 10,000 character threshold.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • fangshuyu-768

Poem

🐰 Hops with glee, a limit change so grand,
Ten thousand runes across the land,
No more per-element constraints to bear,
Comments flow with newfound care!

🚥 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 PR title clearly summarizes the main change: aligning text validation in drive add-comment with the OpenAPI limit (10,000 characters aggregate instead of 1,000 per element).
Description check ✅ Passed The PR description covers all required template sections with substantive content: Summary explains the alignment rationale, Changes lists the key modification, and Test Plan documents executed and remaining tests.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/drive-add-comment-openapi-length-limit

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
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/drive-add-comment-openapi-length-limit -y -g

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.

🧹 Nitpick comments (1)
shortcuts/drive/drive_add_comment_test.go (1)

226-245: Consider making the boundary test exercise rune-count semantics.

Line 229 and Line 230 use ASCII, so this test would still pass if the implementation accidentally used byte length. Using multibyte text keeps the same 10000-character boundary while covering the utf8.RuneCountInString behavior.

🧪 Proposed test-strengthening change
-	first := strings.Repeat("a", 6000)
-	second := strings.Repeat("b", 4000)
+	first := strings.Repeat("界", 6000)
+	second := strings.Repeat("文", 4000)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment_test.go` around lines 226 - 245, The test
TestParseCommentReplyElementsAllowsTextTotalAtOpenAPILimit currently builds
first and second using ASCII characters, so it doesn't catch implementations
that count bytes instead of runes; change the test to use multibyte characters
for first and second (e.g., repeat a multibyte rune like "ह" or an emoji) while
keeping the total rune count at the OpenAI limit (10000) to ensure
parseCommentReplyElements is validated against utf8.RuneCountInString semantics
rather than byte length.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/drive/drive_add_comment_test.go`:
- Around line 226-245: The test
TestParseCommentReplyElementsAllowsTextTotalAtOpenAPILimit currently builds
first and second using ASCII characters, so it doesn't catch implementations
that count bytes instead of runes; change the test to use multibyte characters
for first and second (e.g., repeat a multibyte rune like "ह" or an emoji) while
keeping the total rune count at the OpenAI limit (10000) to ensure
parseCommentReplyElements is validated against utf8.RuneCountInString semantics
rather than byte length.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8026e4a-68eb-4ed1-a2d7-ba1d0133ecb8

📥 Commits

Reviewing files that changed from the base of the PR and between 4da6d61 and 72dacaf.

📒 Files selected for processing (2)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go

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.

1 participant