goshippo / shippo-javascript-sdk

MIT License
5 stars 0 forks source link

Validation issues on `address_from` on unused tracking numbers #19

Closed Cyberuben closed 2 months ago

Cyberuben commented 2 months ago

I have a validation error that occurs on tracking numbers that have not been used yet. For some reason, I have this occurring on two different types of responses. It is unclear if these errors are related to errors in the input when the tracking number was created, or if this is a case the API doesn't handle correctly.

Example 1:

{
    "name": "SDKValidationError",
    "cause": {
        "issues": [
            {
                "code": "invalid_type",
                "expected": "object",
                "received": "undefined",
                "path": [
                    "address_from"
                ],
                "message": "Required"
            }
        ],
        "name": "ZodError"
    },
    "rawValue": {
        "tracking_number": "<REDACTED>",
        "carrier": "fedex",
        "servicelevel": {
            "name": "Home Delivery®",
            "token": "fedex_home_delivery"
        },
        "address_to": {
            "city": "Fairfax",
            "state": "VA",
            "zip": "",
            "country": "US"
        },
        "test": false,
        "tracking_status": {
            "status_date": "2024-02-27T17:35:00Z",
            "status_details": "Shipment information sent to FedEx",
            "location": {
                "city": "",
                "state": "",
                "zip": "92879",
                "country": "US"
            },
            "substatus": {
                "code": "information_received",
                "text": "Information about the package received.",
                "action_required": false
            },
            "object_created": "2024-05-06T12:59:44.862Z",
            "object_updated": "2024-05-06T12:59:44.862Z",
            "object_id": "<REDACTED>",
            "status": "PRE_TRANSIT"
        },
        "tracking_history": [
            {
                "status_date": "2024-02-27T17:35:00Z",
                "status_details": "Shipment information sent to FedEx",
                "location": {
                    "city": "",
                    "state": "",
                    "zip": "92879",
                    "country": "US"
                },
                "substatus": {
                    "code": "information_received",
                    "text": "Information about the package received.",
                    "action_required": false
                },
                "object_created": "2024-05-06T12:59:44.862Z",
                "object_updated": "2024-05-06T12:59:44.862Z",
                "object_id": "<REDACTED>",
                "status": "PRE_TRANSIT"
            }
        ],
        "messages": []
    }
}

As you can see, on the values above, the address_to is set, but lacking a zip entirely. There is no address_from, but the pre-transit information shows a location that does not have a city or state, but does have a zip and country (which are not the same as the address_to.

Example 2:

{
    "name": "SDKValidationError",
    "cause": {
        "issues": [
            {
                "code": "invalid_type",
                "expected": "object",
                "received": "undefined",
                "path": [
                    "address_from"
                ],
                "message": "Required"
            }
        ],
        "name": "ZodError"
    },
    "rawValue": {
        "tracking_number": "<REDACTED>",
        "carrier": "fedex",
        "servicelevel": {
            "name": "SmartPost®",
            "token": "fedex_smart_post"
        },
        "address_to": {
            "city": "Hawthorne",
            "state": "CA",
            "zip": "",
            "country": "US"
        },
        "test": false,
        "tracking_status": {
            "status_date": "2023-10-10T03:19:00Z",
            "status_details": "Arrived at FedEx location",
            "location": {
                "city": "Bloomington",
                "state": "CA",
                "zip": "92316",
                "country": "US"
            },
            "substatus": {
                "code": "package_arrived",
                "text": "Package has arrived at an intermediate location in the carrier network.",
                "action_required": false
            },
            "object_created": "2024-05-06T12:52:40.592Z",
            "object_updated": "2024-05-06T12:52:40.592Z",
            "object_id": "<REDACTED>",
            "status": "TRANSIT"
        },
        "tracking_history": [
            {
                "status_date": "2023-10-09T20:41:35Z",
                "status_details": "Shipment information sent to FedEx",
                "location": {
                    "city": "",
                    "state": "",
                    "zip": "91730",
                    "country": "US"
                },
                "substatus": {
                    "code": "information_received",
                    "text": "Information about the package received.",
                    "action_required": false
                },
                "object_created": "2024-05-06T12:52:40.592Z",
                "object_updated": "2024-05-06T12:52:40.592Z",
                "object_id": "<REDACTED>",
                "status": "PRE_TRANSIT"
            },
            {
                "status_date": "2023-10-10T03:19:00Z",
                "status_details": "Arrived at FedEx location",
                "location": {
                    "city": "Bloomington",
                    "state": "CA",
                    "zip": "92316",
                    "country": "US"
                },
                "substatus": {
                    "code": "package_arrived",
                    "text": "Package has arrived at an intermediate location in the carrier network.",
                    "action_required": false
                },
                "object_created": "2024-05-06T12:52:40.592Z",
                "object_updated": "2024-05-06T12:52:40.592Z",
                "object_id": "<REDACTED>",
                "status": "TRANSIT"
            }
        ],
        "messages": []
    }
}

Just like example 1, there seems to be partial information, even transit information in this case, yet there is no address_from that makes sense here.

Example 3:

{
    "name": "SDKValidationError",
    "cause": {
        "issues": [
            {
                "code": "invalid_type",
                "expected": "object",
                "received": "undefined",
                "path": [
                    "address_from"
                ],
                "message": "Required"
            }
        ],
        "name": "ZodError"
    },
    "rawValue": {
        "tracking_number": "<REDACTED>",
        "carrier": "fedex",
        "servicelevel": {},
        "test": false,
        "tracking_history": [],
        "messages": []
    }
}

In these cases, I don't see any information on the tracking at all, but it is giving me a validation error on address_from, where I think a better detailed error could be thrown, such as not having information on the tracking number altogether. The tracking number has been recorded in our database in January 2024, so its fairly recent, but not that recent.

shippo-lueders commented 2 months ago

I'm confirming with the team whether address_from is actually required; if not, I'll get our spec and SDK updated; if so, I'll file a bug report.

in terms of the inconsistent or missing data in some of these requests, you'll probably need to submit a support request, where you can provide specifics such as your account info and the specific tracking numbers in question so they can help track down what's going on.

shippo-lueders commented 2 months ago

we just released https://www.npmjs.com/package/shippo/v/2.1.3 which should fix the validation errors. closing this issue for now but feel free to re-open if you're still seeing validation failures.