{
  "id": "fix-2526",
  "title": "Outbound Product_Family TiDB Cloud -> TCSA valueMap",
  "kind": "hubspot_sync",
  "linkedIssues": [
    2526
  ],
  "provenance": {
    "businessScenario": "FIX-2526 — re-prove #2526: an outbound Opportunity with Product_Family__c='TiDB Cloud' is mapped via valueMap to HubSpot deal product_family__c='TCSA' (the outbound reverse of the inbound TCSA->TiDB Cloud, per 2.4). Create native Opp (default sync), poll HubSpot_Id__c writeback, PATCH Product_Family__c=TiDB Cloud, confirm NX-side, then poll HubSpot deal product_family__c. PASS (verbatim NEW runbook H FIX-2526): value mapping correct. HubSpot value not TCSA = FAIL (#2526 reproduced); HubSpot_Id__c not written back or NX PATCH not effective = BLOCKED.",
    "reportedBy": "HubSpot sync spec FIX-2526 (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "calibrated": "[calibrated] verified sandbox-legal values: Opp Product_Family__c 'TiDB Cloud' is NX-legal and HubSpot deal product_family__c option 'TCSA' exists; Opp create carries Name+CloseDate+StageName=Prospecting."
  },
  "steps": [
    {
      "id": "account-record-type",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT Id FROM _System_RecordType WHERE SobjectType = 'Account' AND Name = 'Customer' AND IsActive = true LIMIT 1",
      "expectStatus": 200,
      "assertions": [
        {
          "path": "response.body.totalSize",
          "atLeast": 1
        },
        {
          "path": "response.body.records[0].Id",
          "exists": true
        }
      ]
    },
    {
      "id": "create-account",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Account",
      "body": {
        "Name": "Fx2526Acct {{__runId}}",
        "Industry": "FSI-FinTech",
        "NumberOfEmployees": 250,
        "RecordTypeId": "{{steps.account-record-type.response.body.records[0].Id}}",
        "Region__c": "NA",
        "Vertical__c": "Payment",
        "Website": "https://fx2526-acct-{{__runId}}.example.com",
        "ApprovalStatus__c": "Approved"
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "create-opp",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Opportunity",
      "body": {
        "Name": "Fx2526O-{{__runId}}",
        "AccountId": "{{steps.create-account.response.body.id}}",
        "StageName": "Prospecting",
        "ARR_Amount_USD__c": 100000,
        "Launch_Date__c": "2026-12-31",
        "CloseDate": "2026-12-31",
        "HubSpot_Sync_Enabled__c": true
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "wait-hubspot-id",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Opportunity WHERE Id='{{steps.create-opp.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 6000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        }
      ]
    },
    {
      "id": "patch-product-family",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "PATCH",
      "path": "/services/data/v63.0/sobjects/Opportunity/{{steps.create-opp.response.body.id}}",
      "body": {
        "Product_Family__c": "TiDB Cloud"
      },
      "expectStatus": 204
    },
    {
      "id": "confirm-nx",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT Product_Family__c FROM Opportunity WHERE Id='{{steps.create-opp.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "assertions": [
        {
          "path": "response.body.records[0].Product_Family__c",
          "equals": "TiDB Cloud"
        }
      ]
    },
    {
      "id": "assert-hubspot",
      "system": "hubspot",
      "method": "GET",
      "path": "/crm/v3/objects/deals/{{steps.wait-hubspot-id.response.body.records[0].HubSpot_Id__c}}?properties=product_family__c",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 90000,
        "intervalMs": 6000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.properties.product_family__c",
          "equals": "TCSA"
        }
      ]
    }
  ]
}
