fix: align drive add-comment text validation with OpenAPI limit#613
fix: align drive add-comment text validation with OpenAPI limit#613
Conversation
Change-Id: Iab4ceab7c84a7dc0df61825c1835d1a8aca3372f
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughModified 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@72dacafcd1052e565fba1dee4a2f9f55230206de🧩 Skill updatenpx skills add larksuite/cli#fix/drive-add-comment-openapi-length-limit -y -g |
There was a problem hiding this comment.
🧹 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.RuneCountInStringbehavior.🧪 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
📒 Files selected for processing (2)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.go
Summary
This change aligns
drive +add-commentvalidation with the underlying OpenAPI behavior. The CLI previously rejected any singletextreply element longer than 1000 characters, which was stricter than the backend and blocked valid requests.Changes
textlimit indrive +add-commentwith a 10000-character aggregate limit across all caller-providedtextelements.Test Plan
go test ./shortcuts/drive -run 'TestParseCommentReplyElements'make buildmake unit-testlark xxxcommand works as expectedRelated Issues
Summary by CodeRabbit