Drive sync shortcuts declare a scope that does not authorize folder listing
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17.3k
- Forks
- 1.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 105
Description
Summary
drive +push, drive +pull, drive +status, and drive +sync declare
drive:drive.metadata:readonly for recursively listing Drive folders.
However, the shared listing implementation calls:
GET /open-apis/drive/v1/files
The API does not accept drive:drive.metadata:readonly. At runtime it can fail
with 99991679, reporting these alternative scopes:
drive:drivedrive:drive:readonlyspace:document:retrieve
As a result, the shortcut scope preflight succeeds, but execution immediately
fails while listing the target folder.
Version
Confirmed in the latest main commit:
- Commit:
4a56748bfa941ff0ee0bfec92e65acac427732b0 - Release: v1.0.72
Steps to reproduce
-
Authorize a user with the scopes currently declared by
drive +push:drive:drive.metadata:readonlydrive:file:uploadspace:folder:create
-
Run:
lark-cli drive +push \ --local-dir ./local-dir \ --folder-token <folder-token> \ --as user -
The shortcut passes its declared-scope preflight, walks the local directory,
and fails when listing the Drive folder.
Actual behavior
Walking local: ./local-dir
Listing Drive folder: <masked>
{
"ok": false,
"identity": "user",
"error": {
"type": "authorization",
"subtype": "missing_scope",
"code": 99991679,
"message": "unauthorized: user authorization does not cover the required scope(s): drive:drive, drive:drive:readonly, space:document:retrieve",
"missing_scopes": [
"drive:drive",
"drive:drive:readonly",
"space:document:retrieve"
]
}
}
The generated hint asks the user to authorize all three scopes:
lark-cli auth login --scope "drive:drive drive:drive:readonly space:document:retrieve"
These are alternative scopes accepted by the API, so requesting all of them is
unnecessarily broad.
Expected behavior
Before execution, the shortcut should require a scope that actually authorizes
GET /open-apis/drive/v1/files.
If the API exposes several alternative scopes, the CLI should select or
recommend one supported least-privilege scope instead of requiring all
alternatives.
The command documentation should describe the same effective scope requirement.
Relevant code
The affected shortcuts currently declare
drive:drive.metadata:readonly:
shortcuts/drive/drive_push.goshortcuts/drive/drive_pull.goshortcuts/drive/drive_status.goshortcuts/drive/drive_sync.go
They all call the shared recursive listing helper:
shortcuts/drive/list_remote.golistRemoteFolderEntriesGET /open-apis/drive/v1/files
The documentation repeats the same scope assumption:
skills/lark-drive/references/lark-drive-push.mdskills/lark-drive/references/lark-drive-pull.mdskills/lark-drive/references/lark-drive-status.md
The generic missing-scope hint currently joins every reported scope with spaces:
internal/errclass/classify.goPermissionHint
Suggested fix
- Determine which least-privilege scope should be used for
drive.files.list, considering thatdrive:driveand
drive:drive:readonlymay be unavailable under some tenant policies. - Update the four affected shortcuts and their documentation.
- If the scope model supports alternatives, represent this requirement as
“one of” instead of adding every candidate to the conjunctiveScopeslist. - Update the missing-scope hint so API-provided alternatives do not produce an
“authorize everything” command. - Add regression coverage where folder listing returns
99991679even though
drive:drive.metadata:readonlypassed shortcut preflight.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the four shortcut files and shortcuts/drive/list_remote.go to trace the declared scopes into listRemoteFolderEntries and the files endpoint. Then inspect internal/errclass/classify.go and PermissionHint for how reported alternatives are joined, followed by the three drive reference documents. Done means preflight matches the effective least-privilege requirement, alternatives are not treated conjunctively, documentation agrees, and regression coverage covers error 99991679 after the existing preflight.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, authorization, cli, documentation, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100