Skip to content

fix(auth): return validation error when --scope is empty in auth check#999

Merged
JackZhao10086 merged 1 commit into
larksuite:mainfrom
mengqiuzhen:fix/116-auth-check-empty-scope
May 21, 2026
Merged

fix(auth): return validation error when --scope is empty in auth check#999
JackZhao10086 merged 1 commit into
larksuite:mainfrom
mengqiuzhen:fix/116-auth-check-empty-scope

Conversation

@mengqiuzhen

@mengqiuzhen mengqiuzhen commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

auth check --scope "" returned ok: true instead of a validation error. strings.Fields("") produces an empty slice, which matches len(required) == 0, causing the command to report success without checking any scopes.

Fix

Replace the false-positive success path with output.ErrValidation("--scope cannot be empty"), consistent with error handling patterns elsewhere in the auth package.

Changes

  • cmd/auth/check.go: 1 insertion, 2 deletions

Verification

  • go build ./... — clean
  • go test ./cmd/auth/... — all pass (1 pre-existing Windows file-cleanup failure unrelated)

Closes #116

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed auth check --scope validation to properly reject empty scope values with an error instead of returning a success response.

Review Change Stack

strings.Fields("") returns an empty slice, causing --scope "" to bypass
validation and return ok: true. Replace the false-positive success path
with an ErrValidation error so callers correctly detect the invalid input.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6bd77c41-182f-4a1f-8d38-f77713dd3a3a

📥 Commits

Reviewing files that changed from the base of the PR and between 3bab9a0 and 96be0f8.

📒 Files selected for processing (1)
  • cmd/auth/check.go

📝 Walkthrough

Walkthrough

The PR fixes auth check --scope validation: when the scope flag parses to an empty set, the command now returns a validation error instead of reporting success with empty grant/missing lists.

Changes

Empty Scope Validation

Layer / File(s) Summary
Scope empty validation error
cmd/auth/check.go
When the parsed --scope is empty, the command now fails with a validation error rather than treating it as a successful check that grants nothing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

size/L

Suggested reviewers

  • JackZhao10086
  • albertnusouo

Poem

A rabbit found scopes empty as night,
No grant, no miss—just wrong, not right!
Now validation catches this plight,
Returns an error, shining bright! ✨

🚥 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 accurately summarizes the main change: fixing a validation error return for empty --scope in the auth check command.
Description check ✅ Passed The description covers the summary, fix, changes, and verification sections matching the template, though it lacks explicit test plan checkboxes.
Linked Issues check ✅ Passed The PR directly addresses issue #116 by replacing the false-positive success path with a validation error when --scope is empty, exactly as specified in the issue.
Out of Scope Changes check ✅ Passed All changes are limited to cmd/auth/check.go and directly address the validation issue in #116; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

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

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 github-actions Bot added the size/L Large or sensitive change across domains or core paths label May 20, 2026
@JackZhao10086
JackZhao10086 self-requested a review May 21, 2026 03:41
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.67%. Comparing base (6840bb7) to head (96be0f8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cmd/auth/check.go 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #999   +/-   ##
=======================================
  Coverage   67.66%   67.67%           
=======================================
  Files         576      576           
  Lines       54510    54509    -1     
=======================================
+ Hits        36885    36887    +2     
+ Misses      14566    14564    -2     
+ Partials     3059     3058    -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.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@96be0f86e4bd5f6131db6583750a9f49f1e3a1fa

🧩 Skill update

npx skills add mengqiuzhen/Feishu-cli#fix/116-auth-check-empty-scope -y -g

@JackZhao10086
JackZhao10086 merged commit 94b103d into larksuite:main May 21, 2026
17 of 18 checks passed
@liangshuo-1 liangshuo-1 mentioned this pull request May 21, 2026
3 tasks
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
larksuite#999)

strings.Fields("") returns an empty slice, causing --scope "" to bypass
validation and return ok: true. Replace the false-positive success path
with an ErrValidation error so callers correctly detect the invalid input.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

bug: auth check --scope "" bypasses required flag validation and returns ok: true

2 participants