Skip to content

SDKValidationError: Response validation failed with live api token #109

@Robert-Schirmer

Description

@Robert-Schirmer

We recently updated from using a C# shippo sdk to the latest version of the shippo javascript sdk. The javascript sdk works with a test api token but the live token that was previously used for the C# shippo sdk does not and fails with a SDKValidationError.

Calling function

const transaction = await shippo.transactions.create({
      shipment: shipment,
      carrierAccount: carrierInfo.carrierAccount,
      servicelevelToken: carrierInfo.serviceLevel,
      labelFileType: 'PNG',
    });

Bellow error is thrown

SDKValidationError: Response validation failed: [
  {
    "expected": "'UNKNOWN' | 'PRE_TRANSIT' | 'TRANSIT' | 'DELIVERED' | 'RETURNED' | 'FAILURE'",
    "received": "object",
    "code": "invalid_type",
    "path": [
      "tracking_status"
    ],
    "message": "Expected 'UNKNOWN' | 'PRE_TRANSIT' | 'TRANSIT' | 'DELIVERED' | 'RETURNED' | 'FAILURE', received object"
  }
]
    at safeParse (/node_modules/shippo/lib/schemas.js:37:33)
    at matchFunc (/node_modules/shippo/lib/matchers.js:162:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async transactionsCreate (/node_modules/shippo/funcs/transactionsCreate.js:93:22)
    at async unwrapAsync (/node_modules/shippo/types/fp.js:31:15)
    at async ShippoService.createShipment (/dist/sample-shipments/shippo/shippo.service.js:52:29)
    at async SampleShipmentsService.createShipmentInternal (/dist/sample-shipments/sample-shipments.service.js:66:30)
    at async /dist/sample-shipments/sample-shipments.service.js:50:26
caused by: ZodError: [
  {
    "expected": "'UNKNOWN' | 'PRE_TRANSIT' | 'TRANSIT' | 'DELIVERED' | 'RETURNED' | 'FAILURE'",
    "received": "object",
    "code": "invalid_type",
    "path": [
      "tracking_status"
    ],
    "message": "Expected 'UNKNOWN' | 'PRE_TRANSIT' | 'TRANSIT' | 'DELIVERED' | 'RETURNED' | 'FAILURE', received object"
  }
]
    at get error [as error] (/node_modules/zod/lib/types.js:55:31)
    at ZodEffects.parse (/node_modules/zod/lib/types.js:131:22)
    at /node_modules/shippo/lib/matchers.js:162:73
    at safeParse (/node_modules/shippo/lib/schemas.js:34:32)
    at matchFunc (/node_modules/shippo/lib/matchers.js:162:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async transactionsCreate (/node_modules/shippo/funcs/transactionsCreate.js:93:22)
    at async unwrapAsync (/node_modules/shippo/types/fp.js:31:15)
    at async ShippoService.createShipment (/dist/sample-shipments/shippo/shippo.service.js:52:29)
    at async SampleShipmentsService.createShipmentInternal (/dist/sample-shipments/sample-shipments.service.js:66:30)

I'm assuming there is some mismatch in the API version between the test token and the live token? Any help is appreciated

Node version: 20.17.0
Shippo sdk version: 2.15.0

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