Skip to content

Jira link on tests_create/tests_update fails with false "already connected" / duplicate-key error #1640

Description

@1illia1

Summary

Linking multiple tests to the same Jira issue key via the API (tests_create / tests_update, v2 REST) fails intermittently, and a failed attempt leaves state behind that blocks later attempts — even on a test created with no Jira link at all.

Steps to reproduce

  1. Create several tests in one suite, each with link: [{ action: "add", type: "jira", value: "PROJ-123" }].
  2. Fire 6-8 of these calls back-to-back (mixed concurrent/sequential), all linking the same Jira key.

Observed behavior

  • Concurrent/rapid creates: some fail with Mysql2::Error: Duplicate entry 'PROJ-123-Test-8564744' for key 'unique_jiraissues_for_test'. The numeric suffix increments across failures (8564744, 8564745, ..., 8564764), even for brand-new titles never created before — looks like an internal id/sequence collision, not a real duplicate link.
  • Sequential retry of a failed create hits the same duplicate-key error on the next sequence number.
  • Creating without link succeeds normally.
  • Adding the link afterward via PATCH /tests/{id} on that same, freshly-created, link-free test fails with Validation failed: Jira Jira issue already connected for Test <id>. Retrying after several minutes gives the identical error.
  • Two other creates in the same batch failed with Jira issue already connected for Test <id> for ids that don't correspond to any test we created — likely orphaned rows from the failed inserts above.

Impact

Can't reliably bulk-link tests to one Jira issue via the API. Workaround: omit link and keep the Jira key only in the test's free-text description — loses TQL (jira in [...]) and the Jira UI badge.

Suspected root cause

The jiraissues table's id generation isn't safe under back-to-back inserts for the same Jira key, and a failed insert doesn't roll back cleanly — it leaves a dangling row that later blocks unrelated tests from linking to that key.

Environment

  • Testomat.io MCP server, tests_create/tests_update (v2 REST API)
  • Observed 2026-07-31

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions