Skip to content

addCase/updateCase: step custom fields must match TestRail case template #102

@Jyotirmay-Deque

Description

@Jyotirmay-Deque

Problem

When creating or updating test cases via the MCP tools (addCase, updateCase, updateCases), the server sends all optional step-related fields to the TestRail API whenever they are present:

  • custom_steps / custom_expected (template 1)
  • custom_steps_separated (template 2)

TestRail only accepts the fields that belong to the active case template. Sending the wrong combination can result in HTTP 400 responses or fields being silently ignored (e.g. using template 2 but still sending custom_steps / custom_expected).

Expected behavior

  • When templateId is 2, the request body should include custom_steps_separated (and not send template-1-only step fields for those parameters).
  • When templateId is 1, the body should include custom_steps / custom_expected as appropriate (and not send custom_steps_separated for those parameters).
  • custom_preconds (from customPrerequisites) applies to both templates and should continue to be sent when provided.
  • When templateId is omitted, preserve backward compatibility: send whichever step fields the caller provided (current behavior).

Proposed fix

Centralize mapping in a small helper (e.g. buildCaseStepFields) used by addCase, updateCase, and updateCases, branching on templateId as above.

Environment

  • TestRail projects using template 2 (separated steps) are the most affected.
  • Repro: call addCase with templateId: 2, customStepsSeparated, and also pass customSteps/customExpected — observe API error or ignored steps depending on instance.

Issue opened to document background for a focused PR; no unrelated changes (e.g. debug scripts, tool registration refactors).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions