Sitelet https://github.com/gitbucket/gitbucket/pull/4142
Skip to content

Accept only the documented body forms in the add/replace issue labels API - #4142

Open
aadrian wants to merge 2 commits into
gitbucket:masterfrom
aadrian:fix-api-add-labels-array
Open

aadrian wants to merge 2 commits into
gitbucket:masterfrom
aadrian:fix-api-add-labels-array

Conversation

@aadrian

@aadrian aadrian commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

For API compatibility, the add/replace issue labels API should accept the documented body forms: {"labels":["bug"]}, a plain array ["bug"], and a single string "bug". It only handled the object form. json4s reads almost any other JSON into an empty label list without failing, so:

Body Before After
{"labels":["bug"]} works works
["bug"], "bug" POST: nothing added; PUT: all labels deleted labels added / set
[], {"labels":[]} PUT: all labels removed PUT: all labels removed (documented)
{}, null, [1], {"labels":"bug"}, [{"name":"bug"}] 200; PUT: all labels deleted 400, nothing changed

The request body is now matched as raw JSON, and anything else returns 400, like the other API routes do for an unusable body. Added cases to ApiIntegrationTest.

Fixes #3432

@aadrian
aadrian requested a review from takezoe as a code owner September 26, 2026 13:34
@aadrian aadrian changed the title Accept a plain array body in the add/replace issue labels API Accept only the documented body forms in the add/replace issue labels API Sep 26, 2026
@takezoe takezoe added the bug label Sep 27, 2026
@takezoe takezoe added this to the 4.49.0 milestone Sep 27, 2026
aadrian added a commit to aadrian/gitbucket that referenced this pull request Oct 2, 2026
…mented body forms in the add/replace issue labels API
aadrian added a commit to aadrian/gitbucket that referenced this pull request Oct 3, 2026
…mented body forms in the add/replace issue labels API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

"Add labels to an issue" API doesn't work on v4.39.0

2 participants