makeplane / plane

🔥 🔥 🔥 Open Source JIRA, Linear, Monday, and Asana Alternative. Plane helps you track your issues, epics, and product roadmaps in the simplest way possible.
http://plane.so
GNU Affero General Public License v3.0
30.94k stars 1.74k forks source link

[bug]: using API to `PATCH` issue labels causes the label to be **repeated** in API response #5997

Open xmok opened 2 weeks ago

xmok commented 2 weeks ago

Is there an existing issue for this?

Current behavior

When I use the API to PATCH an Issue's Labels, there are 2 issues:

SCENARIO 1. If we PATCH an existing label i.e. an already assigned label, the label is repeated in the DB/Response though the UI only shows unique labels. I would expect the label to not be repeated in the DB. SCENARIO 2. Sending empty array of labels does NOT remove the labels from the API response though it DOES from the UI. I would expect empty array to remove all the labels even from response.

It seems like the UI is using a label_ids field which is different from the labels field returned by API.

Steps to reproduce

curl pseudo

`GET https://api.plane.so/api/v1/workspaces//projects//issues//?fields=labels` response: ``` { "labels": [ "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "1f118077-ea29-4595-81b0-ecb8c6241352", "1f118077-ea29-4595-81b0-ecb8c6241352", "1f118077-ea29-4595-81b0-ecb8c6241352" ] } ``` ``` PATCH https://api.plane.so/api/v1/workspaces//projects//issues// { "labels": ["1f118077-ea29-4595-81b0-ecb8c6241352"] } ``` THEN again: `GET https://api.plane.so/api/v1/workspaces//projects//issues//?fields=labels` response: ``` { "labels": [ "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "c8561e63-3142-4735-a5d9-8af511a4525d", "1f118077-ea29-4595-81b0-ecb8c6241352", "1f118077-ea29-4595-81b0-ecb8c6241352", "1f118077-ea29-4595-81b0-ecb8c6241352", "1f118077-ea29-4595-81b0-ecb8c6241352" ] } ``` NOTICE there are now FOUR of the PATCHed ID.

Videos

ONE: PATCH new label - this video shows that I add a new label using API which is reflected on the UI _but_ the labels in API get the label APPENDED. https://github.com/user-attachments/assets/6696bf8c-931e-47b5-8621-c2884a34d473 TWO: PATCH empty - this video shows that I set labels to empty which a-OK in the UI but the API response still has the labels. https://github.com/user-attachments/assets/5f3d5220-2a42-430c-8747-83d08ee7595c

Environment

Production

Browser

None

Variant

Cloud

Version

Cloud?

aaryan610 commented 2 days ago

Hey @xmok, thanks for noticing this inconsistency. We'll try to fix it with our upcoming release.