fix: webhook update sends a body ClickUp accepts - #8
Merged
Conversation
`webhook update` could not change a webhook's endpoint. Three bugs, all in the request body. `Events` was typed `string`. ClickUp wants an array and answers 400 "Invalid events" (OAUTH_150) to a scalar — for the exact value its own GET returns, so feeding `list` output back through `update` failed. No field had `omitempty`, so an endpoint-only update still sent `"status": ""` and `"events": ""`. ClickUp answers 500 (OAUTH_152) to the empty status. The same update with those keys absent returns 200: PUT here behaves like PATCH and preserves anything the body omits. `--events '*'`, which the flag's own help recommended, is worse than broken: ClickUp answers 200 and sets `events: []`. It unsubscribes the webhook from everything instead of subscribing it to everything. Now refused with an explanation, since a silent unsubscribe on a live webhook has no symptom until the deliveries stop. Also refuse an update with nothing in it rather than sending an empty body. Verified against the live API on a throwaway webhook: endpoint-only, events round-trip, status-only, '*' refused, empty refused. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
webhook updatecould not repoint a webhook's endpoint. Found while moving a live subscription between two agents; the workaround was a rawcurlPUT.Three bugs, all in the request body
1.
Eventswas typedstring. ClickUp wants an array:{"events":"taskStatusUpdated"}400 {"err":"Invalid events","ECODE":"OAUTH_150"}{"events":["taskStatusUpdated"]}200webhook listreturns an array, so round-tripping a value the API just gave you failed.createalready had this right (StringSlice); onlyupdatedid not.2. No
omitempty. An endpoint-only update sent"status": ""and"events": ""along with it:{"endpoint":"…"}200{"endpoint":"…","status":""}500 {"err":"Internal Server Error","ECODE":"OAUTH_152"}The endpoint-only update the CLI could not do is one the API accepts happily.
PUT /v2/webhook/{id}behaves like PATCH — it preserves every field the body omits — so omitempty across the struct is the whole fix.3.
--events '*'silently unsubscribes. The flag help said "use * for all". ClickUp answers200and setsevents: []— subscribing to nothing:That is a live webhook going quiet with no error to notice. Now refused with a message naming why; the help text no longer recommends it.
Plus: an update with no fields at all is refused instead of sending an empty body.
Verification
TestUpdateWebhookBodyasserts the bytes on the wire (endpoint-only omits the other two; events marshal as an array; status alone), because these are payload bugs — asserting on the response would have passed throughout.Against the live API with a throwaway webhook, since a fake server cannot reproduce OAUTH_150/152:
Throwaway webhook deleted after.
Note on the existing suite
cmd.TestParseSincefails onmainatbbfcdffas well — timezone-dependent, unrelated to this change. Everything else passes.Two things I did not touch
webhook listprintssecretin full. It is the HMAC signing key. Worth redacting by default or gating behind a flag.task list --listvswebhook create --list-id- same concept, two flag names.