fix: honor requiredScopes conjunction in CollectScopesForProjects#1878
Open
dc-bytedance wants to merge 1 commit into
Open
fix: honor requiredScopes conjunction in CollectScopesForProjects#1878dc-bytedance wants to merge 1 commit into
dc-bytedance wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesRequired scope collection
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1878 +/- ##
=======================================
Coverage 74.66% 74.67%
=======================================
Files 877 877
Lines 91731 91730 -1
=======================================
+ Hits 68494 68500 +6
+ Misses 17926 17920 -6
+ Partials 5311 5310 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0ac3c230fe77f57d56376fe430be1f3c30ea4225🧩 Skill updatenpx skills add larksuite/cli#fix/collect-scopes-required-scopes -y -g |
1e04d36 to
0ac3c23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CollectScopesForProjectscollected only the single highest-priority scope (bestScope) per API method, dropping the rest of a method'srequiredScopesconjunction, and diverging fromCollectCommandScopes, which already resolves scopes viaDeclaredScopesForMethod.This is a latent defect, not an active user-visible failure. In the current runtime catalog only the mail message
get/batch_getmethods declarerequiredScopes(readonly+subject:read+address:read+body:read). On the single production path that callsCollectScopesForProjects—auth login's domain→scope resolution — the result is unioned with the mail read shortcuts' scopes (mail +message,+messages,+thread, …), which declare the samesubject/address/body:readset, so today the requested scope set is identical with or without this fix. ButrequiredScopesis server-side meta that takes effect without a CLI release: the moment a method with no shortcut coverage gainsrequiredScopes, the under-collection becomes user-visible. This change makes the correct behavior a property of the code rather than a coincidence of the current shortcut declarations.Changes
CollectScopesForProjectsnow resolves scopes viaDeclaredScopesForMethod(the single policy source): it returns a method's fullrequiredScopesset when declared, and otherwise falls back to the recommended single scope. For methods that declare norequiredScopesthe fallback is the samebestScope/LoadScopePrioritiespath as before, so the output is byte-identical — the behavior change is strictly limited to methods that declarerequiredScopes.requiredScopes, so a collected set grows by at most three scopes.LoadScopePrioritiesis package-cached, so resolving per method inside the loop adds no performance regression.Test Plan
go test ./internal/registry/...passesTestCollectScopesForProjects_HonorsRequiredScopes, which asserts the mail message required scopes are collected (runs in CI, not skipped) and pins therequiredScopes-conjunction contractRelated Issues