Skip to content

Handle Composite API errors with statusCode #1854

Open

Description

@vijayprakashpj

Description

Error response from Composite API, specifically, the statusCode attribute is not mapped to SaveError properly.

Sample Response

{
  "success" : false,
  "errors" : [
    {
        "statusCode" : "DUPLICATES_DETECTED",
        "message" : "Use one of these records?",
        "fields" : [ ]
    }
  ]
}

Expected Behaviour

Error responses' statusCode is mapped properly to SaveError while still correctly mapping errorCode as is. Optionally, depending on the implementation approach, SaveError type is modified to accommodate the statusCode.

Actual Behaviour

During runtime, the error response object contains statusCode instead of errorCode. This slips through the type and value checks in the logic.

Workaround

Manually ensure statusCode attribute's presence and extract it for further usage.

Additional Details

Salesforce API version: v65.0
Node version: 26
Library version: 3.10.28
Use case: Create one or many Asset rows with external IDs which fails sometime due to duplicates.

Happy to help/answer any questions 🙂

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions