larksuite / larksuite/cli

[Bug] approval approvals get uses wrong /detail endpoint and rejects bot identity

Open
#2,163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
17.3k
Forks
1.4k
Avg merge
2d 4h
Merged PRs (30d)
105

Description

Summary

In lark-cli v1.0.78, approval approvals get is generated as a user-only command and sends the request to:

GET /open-apis/approval/v4/approvals/{approval_code}/detail

However, the official “Get approval definition” OpenAPI uses:

GET /open-apis/approval/v4/approvals/{approval_code}

and requires a tenant access token. In a real request, the CLI-generated user-identity call returns 2200 Internal Error.

Calling the official endpoint directly with a tenant access token reaches the API successfully and returns the normal actionable permission error 60009 no approval definition permission when the app has not been granted data access to that approval definition. This suggests the CLI metadata has both an incorrect path and an incorrect supported identity.

Environment

  • lark-cli: v1.0.78 (also reproduced on v1.0.69)
  • OS: macOS
  • Brand: Feishu

Steps to reproduce

1. Inspect the generated request
lark-cli approval approvals get   --approval-code TEST_APPROVAL_CODE   --as user   --dry-run

Actual generated request:

{
  "method": "GET",
  "url": "/open-apis/approval/v4/approvals/TEST_APPROVAL_CODE/detail",
  "identity": "user"
}
2. Try the tenant/bot identity
lark-cli approval approvals get   --approval-code TEST_APPROVAL_CODE   --as bot   --dry-run

Actual result:

--as bot is not supported, this command only supports: user
3. Execute with user identity

With a real approval code, the CLI call returns:

{
  "code": 2200,
  "msg": "Internal Error"
}
4. Compare with the native OpenAPI
curl -H "Authorization: Bearer $TENANT_ACCESS_TOKEN"   "https://open.feishu.cn/open-apis/approval/v4/approvals/TEST_APPROVAL_CODE"

The native request reaches the correct API. For an app without approval-definition data authorization, it returns the expected 60009 no approval definition permission instead of the generic 2200 error.

Expected behavior

  • approval approvals get should use /open-apis/approval/v4/approvals/{approval_code} without the /detail suffix.
  • The command should support bot/tenant identity and use a tenant access token, matching the official API.
  • Permission problems should surface the API's actionable error (for example 60009), rather than a generic 2200 Internal Error caused by the wrong request metadata.

Related

Related to #780, which reports broken approval user-identity metadata/scopes. This issue adds a concrete wrong endpoint and bot-identity rejection for approval approvals get.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the implementation or generated metadata for the approval approvals get command and reproduce its --dry-run request. Compare the command's path and supported identity with the official Get approval definition request described here. Done means the command uses the expected endpoint and accepts tenant/bot identity, with tests or dry-run output covering both changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.