task: PATCH custom_fields returns 1470403 with DPoP user token, works with Bearer

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
api, cli

Research direction

The bug sits in the DPoP token path of the Go CLI when calling the Lark task v2 PATCH endpoint with update_fields custom_fields. Start from the repro: config set dpop preferred, then task tasks patch with custom_fields. Compare the request against a Bearer run to find where the permission check diverges. Done means a DPoP-bound user token can update a custom field on an existing task and the Bearer path is unchanged.

Written by the indexing model from the issue text.

Description

bug domain/auth domain/core domain/task

Summary

With a DPoP-bound user access token, updating a custom field value on an existing task (PATCH /open-apis/task/v2/tasks/:task_guid with update_fields: ["custom_fields"]) always fails with 1470403 ("user lacks permission for the requested resource"). The same request succeeds after re-authorizing with lark-cli config set dpop disabled (Bearer token). Other operations work fine with the DPoP token, including setting custom field values at task creation.

Environment

  • lark-cli 1.0.98 (npm), Windows 11, brand lark
  • DPoP mode preferred, key provider windows-platform-ksp
  • User identity (--as user), the user is the owner of the tasklist and creator/assignee of the task

Steps to reproduce

  1. lark-cli config set dpop preferred, then lark-cli auth login --recommend (token type: DPoP; scopes include task:task:write and task:custom_field:write).
  2. Create a tasklist, then a single-select or text custom field on it (task custom_fields create, resource_type: tasklist).
  3. Create a task in that tasklist.
  4. Update the field value:
lark-cli task tasks patch --as user --params '{"task_guid":"<TASK_GUID>"}' \
  --data '{"task":{"custom_fields":[{"guid":"<FIELD_GUID>","text_value":"x"}]},"update_fields":["custom_fields"]}'

Actual result

"code": 1470403,
"message": "user lacks permission for the requested resource"

Expected result

The value is updated, as it is in the Lark client by the same user, and as it is with a Bearer token.

What we checked (all with the same user and app)

Token Scopes Operation Result
DPoP task, contact, wiki, docs, drive, base, sheets, calendar, vc PATCH custom_fields on existing task 1470403
DPoP --recommend (all) PATCH custom_fields on existing task 1470403
Bearer --recommend (all) PATCH custom_fields on existing task OK
DPoP any of the above PATCH summary on the same task OK
DPoP any of the above PATCH summary + custom_fields together 1470403
DPoP any of the above create task with custom_fields values OK
DPoP any of the above raw lark-cli api PATCH ... 1470403
  • Single-select and text fields behave the same.
  • Adding the user explicitly as editor member, or adding the app as a tasklist member, does not help.
  • The same user can set the value in the Lark client without problems.

So the field permission check on task update seems not to accept DPoP-bound user tokens, while task edit permission and field writes on create do.

Workaround

lark-cli config set dpop disabled and re-authorize (Bearer token).

Dominant language
Go
Stars
18.2k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
18

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

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.

More from larksuite/cli

All issues in larksuite/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.