Skip to content

fix: validate auth login scopes locally#454

Draft
lttlin wants to merge 1 commit intolarksuite:mainfrom
lttlin:fix/416-auth-scope-validation
Draft

fix: validate auth login scopes locally#454
lttlin wants to merge 1 commit intolarksuite:mainfrom
lttlin:fix/416-auth-scope-validation

Conversation

@lttlin
Copy link
Copy Markdown

@lttlin lttlin commented Apr 13, 2026

Problem

lark-cli auth login --scope currently forwards the raw scope string to the device authorization endpoint. If the input contains malformed spacing, line breaks, or a typo in one scope name, the user only sees the remote OAuth error saying the scope list is invalid, without any indication of which scope caused it.

Root Cause

The explicit --scope path does not normalize user input or validate the requested scope names against the CLI's known scope registry before making the device authorization request.

Fix

Normalize explicit scope input with strings.Fields, deduplicate repeated entries, and validate each requested scope against the union of known registry scopes and shortcut scopes before calling the OAuth device authorization endpoint. Invalid scope names now fail fast with a local validation error that points users to auth scopes or the domain-based recommend flow.

Validation

  • Static code review of the new auth login validation path
  • Added unit tests covering whitespace normalization, invalid scope rejection, and early failure before network calls

Closes #416

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 303135b5-da30-4436-a222-c60081536899

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the size/L Large or sensitive change across domains or core paths label Apr 13, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


voita seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

授权失败的时候希望能给详细的列表原因

2 participants