feat(approval/instances): 审批相关命令无法通过 instance_id 获取 instance_code
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17.3k
- Forks
- 1.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 105
Description
首先感谢项目维护人员的大力支持,致敬~
背景
用户从飞书审批页面的GUI中获取到一个审批实例链接,格式为 https://go.feishu.cn/approval/s/xxxxxxxx/。目标是通过AI Agent工具对该审批进行批量抄送等自动化操作。
当前现状
1. Open API 方式
通过跟踪上述短链接,可以获取到 instance_id:
$ curl -I https://go.feishu.cn/approval/s/xxxxxxxx/
Location: https://oa.feishu.cn/approval/web/api/ShortToLong?InstanceID=xxxxxxxxxxxxxxxxxxx&UserID=xxxxxxxxxxxxxxxxxxx
随后,可以使用 Open API 接口 查询用户的任务列表 并指定 topic=3(已发起审批)来查询相关任务:
POST https://open.feishu.cn/open-apis/approval/v4/tasks/query
返回示例:
{
"code": 0,
"msg": "success",
"data": {
"tasks": [
{
"topic": "1",
"user_id": "example_user_id",
"title": "任务题目示例",
"urls": {
"helpdesk": "https://blabla",
"mobile": "https://blabla",
"pc": "https://blabla"
},
"process_external_id": "example_instance_id",
"task_external_id": "example_task_id",
"status": "Todo",
"process_status": "Running",
"definition_code": "000000-00000000000000-0example",
"initiators": [
"starter"
],
"initiator_names": [
"发起人姓名"
],
"task_id": "1212564555454",
"process_id": "1214564545474",
"process_code": "123e4567-e89b-12d3-a456-426655440000",
"definition_group_id": "1212564555454",
"definition_group_name": "流程定义名称",
"definition_id": "1212564555454",
"definition_name": "流程定义组名称"
}
],
"page_token": "example_page_token",
"has_more": true,
"count": {
"total": 123,
"has_more": false
}
}
}
其中:
process_id对应instance_idprocess_code对应instance_code
通过上一步获得的 instance_id 进行匹配,可获取对应的 instance_code。
2. lark-cli 方式
approval tasks query 不支持 --topic 3
执行以下命令:
$ lark-cli approval tasks query --topic 3
返回错误:
{
"ok": false,
"identity": "user",
"error": {
"type": "api",
"subtype": "invalid_parameters",
"code": 99992402,
"message": "field validation failed",
"log_id": "x",
"troubleshooter": "x"
}
}
补充说明:
approval tasks query 的帮助文档中虽标明支持 3=已发起审批,但实际并不支持。而SKILL文档中仅注明支持 1=待办审批、2=已办审批、17=未读知会、18=已读知会。
$ lark-cli approval tasks query --help
...
API Parameters:
Required:
--topic string 需要查询的任务分组主题,如「待办」、「已办」等. enum: 1=待办审批|2=已办审批|3=已发起审批|17=未读知会|18=已读知会
...
approval instances initiated 缺少 instance_id
根据SKILL建议,使用 approval instances initiated 查询当前用户已发起审批实例列表,返回结果中仅包含 instance_code,未提供 instance_id。
$ lark-cli approval instances initiated
返回示例:
{
"ok": true,
"identity": "user",
"data": {
"count": 1,
"has_more": false,
"instances": [
{
"definition_code": "x-x-x-x-x",
"definition_group_id": "x",
"definition_group_name": "人力资源管理",
"definition_name": "补卡",
"initiator": "ou_x",
"initiator_name": "xxx",
"instance_code": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"instance_status": 1,
"summaries": [
{
"key": "x",
"value": "x"
}
]
}
]
}
}
期望
为简化通过审批链接获取 instance_code 的流程,建议考虑以下任一方案:
- 在飞书审批GUI页面中提供可直接获取
instance_code的入口; - 在复制审批链接时,将
instance_code信息一并包含; - 提供通过
instance_id查询对应instance_code的Open API接口; - 修复
approval tasks query接口,使其支持--topic 3参数; - 在
approval instances initiated的返回结果中增加instance_id字段。
环境信息
- lark-cli 版本:
1.0.87 - 相关命令:
approval instances initiated、approval tasks query
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 by reproducing approval tasks query --topic 3 and approval instances initiated with lark-cli 1.0.87, then inspect the approval command implementations and their Open API parameter and response mappings. Done should be a clearly selected resolution that lets users obtain or correlate instance_id and instance_code, with the help text and returned fields matching the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100