Skip to content

fix: reject truncated wiki node tokens - #2203

Merged
liujinkun2025 merged 1 commit into
mainfrom
fix/reject-short-wiki-tokens
Aug 6, 2026
Merged

fix: reject truncated wiki node tokens#2203
liujinkun2025 merged 1 commit into
mainfrom
fix/reject-short-wiki-tokens

Conversation

@liujinkun2025

@liujinkun2025 liujinkun2025 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reject incomplete Wiki resource tokens before wiki +node-get sends an OpenAPI request. Complete Lark resource tokens are 27 characters long, so shorter values such as the observed five-character PImXw input now fail locally instead of contributing to the OpenAPI not-found rate.

Changes

  • Add a shared 27-character minimum-length validator for Wiki resource tokens.
  • Apply the validator during wiki +node-get argument parsing, before any HTTP request.
  • Return a typed validation/invalid_argument error with actionable guidance.
  • Add explicit 26/27-character boundary coverage.
  • Add unit and dry-run E2E coverage, including an assertion that invalid input never reaches the HTTP transport.

Test Plan

  • go test ./shortcuts/wiki
  • LARK_CLI_BIN=<freshly-built-binary> go test ./tests/cli_e2e/wiki -run TestWikiNodeGetDryRunRejectsTruncatedToken -count=1
  • Manual local verification confirms lark-cli wiki +node-get --node-token PImXw --dry-run exits with a typed validation error.

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes
    • Wiki commands now reject incomplete or truncated resource tokens shorter than 27 characters.
    • Validation identifies the invalid --node-token and explains how to provide a complete token or full URL.
    • Invalid tokens are rejected before network requests are made.
    • Dry-run commands now report structured validation errors with the correct exit status.
    • Improved handling of token length boundaries and malformed token input.

@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 Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds a 27-character minimum for Wiki resource tokens. Truncated --node-token values now return structured invalid-argument errors before any HTTP request.

Changes

Wiki node-token validation

Layer / File(s) Summary
Token length validation
shortcuts/wiki/wiki_token_validation.go
The wiki package rejects resource tokens shorter than 27 characters and provides guidance to use a complete token or full Lark URL.
Node-get validation integration
shortcuts/wiki/wiki_node_get.go, shortcuts/wiki/wiki_node_get_test.go, tests/cli_e2e/wiki/wiki_node_get_dryrun_test.go
wiki +node-get validates the resolved token before continuing. Unit and end-to-end tests verify structured errors, boundary handling, hints, exit status, empty stdout, no HTTP request, and shared token fixtures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: fangshuyu-768

🚥 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 title clearly and concisely describes the main change: rejecting truncated Wiki node tokens.
Description check ✅ Passed The description includes all required sections and clearly documents the changes, validation, tests, and related issues.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reject-short-wiki-tokens

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.

@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/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

📥 Commits

Reviewing files that changed from the base of the PR and between 50b4c68 and 92dde62.

📒 Files selected for processing (4)
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_get_test.go
  • shortcuts/wiki/wiki_token_validation.go
  • tests/cli_e2e/wiki/wiki_node_get_dryrun_test.go

Comment thread shortcuts/wiki/wiki_node_get_test.go
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@6220fe3fd4b01e1485f0443c324534227247b02d

🧩 Skill update

npx skills add larksuite/cli#fix/reject-short-wiki-tokens -y -g

@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/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

📥 Commits

Reviewing files that changed from the base of the PR and between 92dde62 and 1108ac3.

📒 Files selected for processing (2)
  • shortcuts/wiki/wiki_node_get_test.go
  • shortcuts/wiki/wiki_token_validation.go

Comment thread shortcuts/wiki/wiki_node_get_test.go
@liujinkun2025
liujinkun2025 force-pushed the fix/reject-short-wiki-tokens branch from ac67b6d to ef5d294 Compare August 6, 2026 04:46
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

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.

@liujinkun2025
liujinkun2025 force-pushed the fix/reject-short-wiki-tokens branch from ef5d294 to bdb42c4 Compare August 6, 2026 04:52
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

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.

Comment thread shortcuts/wiki/wiki_token_validation.go
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.22%. Comparing base (fcdef49) to head (6220fe3).
⚠️ Report is 10 commits behind head on main.

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.
📢 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.

ViperCai
ViperCai previously approved these changes Aug 6, 2026

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@liujinkun2025
liujinkun2025 merged commit f7d0326 into main Aug 6, 2026
27 checks passed
@liujinkun2025
liujinkun2025 deleted the fix/reject-short-wiki-tokens branch August 6, 2026 14:08
@liangshuo-1 liangshuo-1 mentioned this pull request Aug 7, 2026
3 tasks
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.

3 participants