Skip to content

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

Open

Description

@alxwlw

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

Activity

  1. MishraTanishq619 commented on Nov 6, 2026

    @MishraTanishq619

    I am exploring this issue.

  2. MishraTanishq619 commented on Nov 6, 2026

    @MishraTanishq619

    I reproduced this on preview (618d0eb).
    The update path (PATCH .../comments/{id}/) has the same problem, and the 409 on create can return a comment from another work item.
    Attachments already scope this check by issue_id, so I've done the same for comments, with contract tests.

    Opening a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions