fix: reject truncated wiki node tokens - #2203
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds a 27-character minimum for Wiki resource tokens. Truncated ChangesWiki node-token validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
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/wiki/wiki_node_get_test.go`:
- Around line 150-171: The test coverage in
TestParseWikiNodeGetSpecRejectsTruncatedToken only checks a short raw token;
extend it to verify the acceptance boundary and URL extraction branch. Add
assertions that raw token “PImXw1” succeeds and that a supported /wiki/PImXw URL
is rejected with the same validation details, including the --node-token
parameter and actionable hint.
🪄 Autofix
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 Plus
Run ID: 3fc4d13b-1f29-4490-8eda-cc9e30892350
📒 Files selected for processing (4)
shortcuts/wiki/wiki_node_get.goshortcuts/wiki/wiki_node_get_test.goshortcuts/wiki/wiki_token_validation.gotests/cli_e2e/wiki/wiki_node_get_dryrun_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@6220fe3fd4b01e1485f0443c324534227247b02d🧩 Skill updatenpx skills add larksuite/cli#fix/reject-short-wiki-tokens -y -g |
There was a problem hiding this comment.
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/wiki/wiki_node_get_test.go`:
- Around line 183-185: Update TestValidateWikiResourceTokenLengthBoundary to
inspect the returned error with errs.ProblemOf(err), asserting
CategoryValidation and SubtypeInvalidArgument, then type-assert
*errs.ValidationError and verify its Param is "--node-token". If the validation
error exposes a wrapped cause, assert that the cause is preserved as well while
retaining the existing rejection assertion.
🪄 Autofix
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 Plus
Run ID: 8d8deb1f-dc35-44f5-9506-35bfcaef16da
📒 Files selected for processing (2)
shortcuts/wiki/wiki_node_get_test.goshortcuts/wiki/wiki_token_validation.go
ac67b6d to
ef5d294
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
ef5d294 to
bdb42c4
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
bdb42c4 to
eaaa1f8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2203 +/- ##
==========================================
+ Coverage 76.10% 76.22% +0.11%
==========================================
Files 983 987 +4
Lines 103079 104280 +1201
==========================================
+ Hits 78448 79484 +1036
- Misses 18694 18752 +58
- Partials 5937 6044 +107 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
eaaa1f8 to
6220fe3
Compare
fangshuyu-768
left a comment
There was a problem hiding this comment.
Re-reviewed at 6220fe3. With product confirmation that all currently supported production Wiki resource tokens are 27 characters, the previous short opaque-token concern is not actionable. The validation path, typed error contract, transport short-circuit, and 26/27-character boundary coverage are correct. Targeted local verification and the full CI suite, including live E2E, pass.
Summary
Reject incomplete Wiki resource tokens before
wiki +node-getsends an OpenAPI request. Complete Lark resource tokens are 27 characters long, so shorter values such as the observed five-characterPImXwinput now fail locally instead of contributing to the OpenAPI not-found rate.Changes
wiki +node-getargument parsing, before any HTTP request.validation/invalid_argumenterror with actionable guidance.Test Plan
go test ./shortcuts/wikiLARK_CLI_BIN=<freshly-built-binary> go test ./tests/cli_e2e/wiki -run TestWikiNodeGetDryRunRejectsTruncatedToken -count=1lark-cli wiki +node-get --node-token PImXw --dry-runexits with a typed validation error.Related Issues
Summary by CodeRabbit
--node-tokenand explains how to provide a complete token or full URL.