{
  "id": "LC-CONTACT-ACCOUNT-MISMATCH",
  "name": "convertLead rejects reused Contact belonging to a different Account",
  "description": "Phase-1 Finding-2 regression: the flow validates that caller-supplied contactId resolves, but prior to the ValidateContactAccountConsistency decision it never cross-checked that the reused Contact's AccountId matched the resolved/created accountId. A caller could therefore reuse Contact C from Account X but create/select Account Y, producing an inconsistent (ConvertedAccountId=Y, ConvertedContactId=C) pair on the Lead. This path is new in PR #1834 — the legacy handler (deleted in 372c6121) didn't accept contactId/opportunityId at all. Setup seeds a Contact whose AccountId differs from the supplied accountId; the flow must fault with SF-native INVALID_CROSS_REFERENCE_KEY.",
  "object": "LeadConvert",
  "method": "POST",
  "endpoint": "/services/data/v63.0/actions/standard/convertLead",
  "setup": [
    {
      "type": "sql",
      "sql": "INSERT INTO `Account` (Id, Name, OwnerId, CreatedDate, LastModifiedDate, IsDeleted) VALUES ('lcmm_acct_A', 'LCMM Account A', '{user_id}', NOW(), NOW(), 0), ('lcmm_acct_B', 'LCMM Account B', '{user_id}', NOW(), NOW(), 0) ON DUPLICATE KEY UPDATE Name=VALUES(Name), LastModifiedDate=NOW(), IsDeleted=0"
    },
    {
      "type": "sql",
      "sql": "INSERT INTO `Contact` (Id, LastName, AccountId, OwnerId, CreatedDate, LastModifiedDate, IsDeleted) VALUES ('lcmm_cont_B', 'MismatchedContact', 'lcmm_acct_B', '{user_id}', NOW(), NOW(), 0) ON DUPLICATE KEY UPDATE LastName=VALUES(LastName), AccountId=VALUES(AccountId), LastModifiedDate=NOW(), IsDeleted=0"
    }
  ],
  "payload": {
    "inputs": [
      {
        "leadId": "{seed_Lead_0}",
        "convertedStatus": "Converted",
        "accountId": "lcmm_acct_A",
        "contactId": "lcmm_cont_B",
        "doNotCreateOpportunity": true
      }
    ]
  },
  "expects": {
    "status_code": 200
  },
  "response_assertions": [
    {"field": "0.isSuccess", "operator": "eq", "value": false},
    {"field": "0.errors.0.statusCode", "operator": "eq", "value": "INVALID_CROSS_REFERENCE_KEY"},
    {"field": "0.errors.0.message", "operator": "contains", "value": "different Account"},
    {"field": "0.errors.0.message", "operator": "not_contains", "value": "internal error"},
    {"field": "0.errors.0.message", "operator": "not_contains", "value": "ValidateContactAccountConsistency"}
  ],
  "teardown": [
    {
      "type": "sql",
      "sql": "DELETE FROM `Contact` WHERE Id = 'lcmm_cont_B'"
    },
    {
      "type": "sql",
      "sql": "DELETE FROM `Account` WHERE Id IN ('lcmm_acct_A', 'lcmm_acct_B')"
    }
  ],
  "priority": "P0",
  "scene": "lead_convert"
}
