goshippo / shippo-javascript-sdk

MIT License
5 stars 0 forks source link

zod invalid enum value on shipments.create with a previously validated toAddress #59

Closed alsoscotland closed 3 weeks ago

alsoscotland commented 3 weeks ago

I am seeing another zod error on the response of a shipments.create request. I am passing a previously validated objectId in the addressTo field and receiving the following

"error": {
        "msg": "shipping label rate quote error",
        "originalError": {
            "name": "SDKValidationError",
            "cause": {
                "issues": [
                    {
                        "received": "address_abbreviation_fixed",
                        "code": "invalid_enum_value",
                        "options": [
                            "verification_error",
                            "unknown_street",
                            "component_mismatch_error",
                            "multiple_match",
                            "sub_premise_number_invalid",
                            "sub_premise_number_missing",
                            "premise_number_invalid",
                            "premise_number_missing",
                            "box_number_invalid",
                            "box_number_missing",
                            "pmb_number_missing",
                            "postal_code_change",
                            "administrative_area_change",
                            "locality_change",
                            "dependent_locality_change",
                            "street_name_change",
                            "street_type_change",
                            "street_directional_change",
                            "sub_premise_type_change",
                            "sub_premise_number_change",
                            "double_dependent_locality_change",
                            "subadministrative_area_change",
                            "subnational_area_change",
                            "po_box_change",
                            "premise_type_change",
                            "house_number_change",
                            "organization_change",
                            "extraneous_information",
                            "usps_door_inaccessible",
                            "administrative_area_partial",
                            "city_partial",
                            "street_partial",
                            "building_partial",
                            "subpremise_partial",
                            "administrative_area_full",
                            "city_full",
                            "thoroughfare_full",
                            "premises_full",
                            "subpremise_full",
                            "geocoded_street",
                            "geocoded_neighborhood",
                            "geocoded_community",
                            "geocoded_state",
                            "geocoded_rooftop",
                            "geocoded_interpolated_rooftop",
                            "invalid_postal_code",
                            "postal_code_not_found",
                            "empty_request",
                            "service_error",
                            "street_detail_missing",
                            "Invalid City/State/Zip",
                            "Default Match",
                            "Unknown Street",
                            "Address Not Found",
                            "Non-Deliverable ZIP4",
                            "Multiple Responses",
                            "Invalid Dual Address",
                            "Invalid State",
                            "Invalid City",
                            "Ambiguous Address"
                        ],
                        "path": [
                            "address_to",
                            "validation_results",
                            "messages",
                            0,
                            "code"
                        ],
                        "message": "Invalid enum value. Expected 'verification_error' | 'unknown_street' | 'component_mismatch_error' | 'multiple_match' | 'sub_premise_number_invalid' | 'sub_premise_number_missing' | 'premise_number_invalid' | 'premise_number_missing' | 'box_number_invalid' | 'box_number_missing' | 'pmb_number_missing' | 'postal_code_change' | 'administrative_area_change' | 'locality_change' | 'dependent_locality_change' | 'street_name_change' | 'street_type_change' | 'street_directional_change' | 'sub_premise_type_change' | 'sub_premise_number_change' | 'double_dependent_locality_change' | 'subadministrative_area_change' | 'subnational_area_change' | 'po_box_change' | 'premise_type_change' | 'house_number_change' | 'organization_change' | 'extraneous_information' | 'usps_door_inaccessible' | 'administrative_area_partial' | 'city_partial' | 'street_partial' | 'building_partial' | 'subpremise_partial' | 'administrative_area_full' | 'city_full' | 'thoroughfare_full' | 'premises_full' | 'subpremise_full' | 'geocoded_street' | 'geocoded_neighborhood' | 'geocoded_community' | 'geocoded_state' | 'geocoded_rooftop' | 'geocoded_interpolated_rooftop' | 'invalid_postal_code' | 'postal_code_not_found' | 'empty_request' | 'service_error' | 'street_detail_missing' | 'Invalid City/State/Zip' | 'Default Match' | 'Unknown Street' | 'Address Not Found' | 'Non-Deliverable ZIP4' | 'Multiple Responses' | 'Invalid Dual Address' | 'Invalid State' | 'Invalid City' | 'Ambiguous Address', received 'address_abbreviation_fixed'"
                    },
                    {
                        "received": "addresses_ms",
                        "code": "invalid_enum_value",
                        "options": [
                            "Shippo Address Validator",
                            "UPS"
                        ],
                        "path": [
                            "address_to",
                            "validation_results",
                            "messages",
                            0,
                            "source"
                        ],
                        "message": "Invalid enum value. Expected 'Shippo Address Validator' | 'UPS', received 'addresses_ms'"
                    }
                ],
                "name": "ZodError"
            }

Here is the objectId result of the request "object_id": "4eb9cd1bcf9242baa3143bc9f31c394b", "object_created": "2024-06-12T19:31:43.405Z", "object_updated": "2024-06-12T19:31:44.827Z",

and I am sending the object id of a previously validated address which has the following validation results

objectid: 4347bcce24a94f77893ee72ce05ce10b "validation_results": { "is_valid": true, "messages": [ { "source": "addresses_ms", "code": "address_abbreviation_fixed", "text": "The address abbreviation was changed (such as \"Street\" to \"St\")", "type": "address_correction" } ] }

shippo-lueders commented 3 weeks ago

should have a fix out by tomorrow

shippo-lueders commented 3 weeks ago

fixed in https://www.npmjs.com/package/shippo/v/2.3.4

just FYI, this represents a targeted change but we're moving to enums on input, strings on output. most of the enums we have in the spec will actually evolve over time, and since enums are a closed set, if an sdk receives a value it doesn't understand, the call will explode. to sidestep this issue, we're going to drop enums from our output models altogether, so you'll hopefully stop seeing this type of error in the near future.