[bug]: Comment external_id is deduplicated per project instead of per work item

Open Beginner friendly
#10,195 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, postgresql, python
Domain
api, backend, databases

Research direction

Read apps/api/plane/api/views/issue.py around lines 1565 and 1735, where comment creation and update check for duplicate external IDs. Trace how the endpoint identifies the current work item and compare that with the project scoped filter described in the issue. Done means the same external source and ID can be used on different work items in one project, while a repeat on the same work item still returns 409; verify both cases through the comments API.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current behavior

Creating a work item comment with external_source and external_id returns 409 when any work item in the same project already has a comment with that pair. The check belongs to one work item's comment endpoint, but it filters by project only:

apps/api/plane/api/views/issue.py:1565 (create) and :1735 (update), branch preview:

IssueComment.objects.filter(
    project_id=project_id,
    workspace__slug=slug,
    external_source=...,
    external_id=...,
).exists()

So one external event that touches several work items in a project, written with one key per event, can record a comment on the first work item only. The rest get 409, and the id in the response points to a comment on a different work item.

Steps to reproduce
  1. Take two work items A and B in one project.
  2. Create a comment on A:
curl -X POST "$HOST/api/v1/workspaces/$SLUG/projects/$PROJECT/work-items/$A/comments/" \
  -H "X-API-Key: $KEY" -H 'Content-Type: application/json' \
  -d '{"comment_html":"<p>probe</p>","external_source":"probe","external_id":"scope-1"}'

Result: 201.

  1. Send the same request for B.

Result: 409 with {"error":"Work item comment with the same external id and external source already exists","id":"<id of the comment on A>"}.

Expected: 201 on B. The 409 should apply only to a repeat on the same work item, by adding issue_id to the filter. If project-wide uniqueness is intended, it would help to say so in the API docs.

Environment

Production

Browser

Other

Edition

Commercial

Version

v3.3.0

Dominant language
TypeScript
Stars
61.9k
Forks
6.3k
Avg merge
1d 18h
Merged PRs (30d)
75

Getting set up

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 makeplane/plane

All issues in makeplane/plane

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.