{"record":{"id":"9df1c92362ca70ae","repo":"juspay/hyperswitch","slug":"invalid-worldpayxml-metadata-format","errorCode":null,"errorMessage":"Invalid Worldpayxml metadata format","messagePattern":"Invalid Worldpayxml metadata format","errorType":"error_code","errorClass":"ApiErrorResponse","httpStatus":500,"severity":"error","filePath":"crates/router/src/core/unified_connector_service/connector_config.rs","lineNumber":1572,"sourceCode":"                    api_secret,\n                } => Ok(Self::Worldpay {\n                    username: key1.clone(),\n                    password: api_key.clone(),\n                    entity_id: api_secret.clone(),\n                    merchant_name: None,\n                }),\n                _ => Err(err(\"Worldpay requires SignatureKey auth type\")),\n            },\n            Connector::Worldpayxml => match auth {\n                ConnectorAuthType::SignatureKey {\n                    api_key,\n                    key1,\n                    api_secret,\n                } => {\n                    let worldpayxml_meta = metadata\n                        .map(|m| {\n                            serde_json::from_value::<WorldpayxmlMetadata>(m.clone())\n                                .map_err(|_| err(\"Invalid Worldpayxml metadata format\"))\n                        })\n                        .transpose()?;\n\n                    Ok(Self::Worldpayxml {\n                        api_username: api_key.clone(),\n                        api_password: key1.clone(),\n                        merchant_code: api_secret.clone(),\n                        issuer_id: worldpayxml_meta.as_ref().and_then(|m| m.issuer_id.clone()),\n                        organizational_unit_id: worldpayxml_meta\n                            .as_ref()\n                            .and_then(|m| m.organizational_unit_id.clone()),\n                        jwt_mac_key: worldpayxml_meta.as_ref().and_then(|m| m.jwt_mac_key.clone()),\n                    })\n                }\n                _ => Err(err(\"Worldpayxml requires SignatureKey auth type\")),\n            },\n            Connector::Zift => match auth {\n                ConnectorAuthType::SignatureKey {","sourceCodeStart":1554,"sourceCodeEnd":1590,"githubUrl":"https://github.com/juspay/hyperswitch/blob/3093f22cc46b46415cca152ea0b234277b251ecd/crates/router/src/core/unified_connector_service/connector_config.rs#L1554-L1590","documentation":"This error is raised when configuring the Worldpayxml connector in Hyperswitch's unified connector service: the caller supplied a `metadata` JSON value, but `serde_json::from_value::<WorldpayxmlMetadata>` failed to deserialize it into the expected `WorldpayxmlMetadata` struct. The underlying serde error is discarded (`map_err(|_| ...)`) and replaced by this opaque message, so any shape mismatch — wrong types, unknown/misspelled fields with deny-unknown-fields, or a non-object value — surfaces as this error. It indicates the merchant_connector_account metadata for Worldpayxml is malformed, not that credentials are wrong.","triggerScenarios":"Calling the connector config conversion (e.g. when creating/updating a merchant connector account or building connector data for Worldpayxml) with `ConnectorAuthType::SignatureKey` and a `metadata` field that is not a valid `WorldpayxmlMetadata` JSON object — e.g. `\"issuer_id\": 123` (number instead of string), a metadata JSON string instead of an object, or unexpected/invalid fields.","commonSituations":"Hand-editing connector metadata in the dashboard or via API and mistyping a field name or type; copying metadata from another connector whose schema differs; an API client sending metadata as a JSON-encoded string rather than a nested object; schema changes to WorldpayxmlMetadata between Hyperswitch versions making older payloads invalid.","solutions":["Inspect the `metadata` JSON value sent for the Worldpayxml merchant connector account and make it match the `WorldpayxmlMetadata` struct (all fields optional strings: issuer_id, organizational_unit_id, jwt_mac_key).","Ensure metadata is a JSON object (not a string or array) and that string-typed fields are not numbers/booleans/null where a string is required.","Remove unknown or misspelled keys from metadata, or temporarily omit metadata entirely — it is optional (`metadata.map(...)`) and omitted metadata is accepted.","If the payload looks correct, deserialize locally against the current `WorldpayxmlMetadata` definition in your Hyperswitch version to see the real serde error (the thrown error hides it)."],"exampleFix":"// before\nmetadata = \"{\\\"issuer_id\\\": 12345}\"  // metadata sent as JSON string with numeric issuer_id\n// after\nmetadata = {\"issuer_id\": \"12345\", \"organizational_unit_id\": \"ou-abc\"}  // proper object with string values","handlingStrategy":"validation","validationCode":"fn validate_worldpayxml_metadata(metadata: &serde_json::Value) -> Result<(), String> {\n    if !metadata.is_object() {\n        return Err(\"metadata must be a JSON object\".into());\n    }\n    for key in [\"issuer_id\", \"organizational_unit_id\", \"jwt_mac_key\"] {\n        if let Some(v) = metadata.get(key) {\n            if !v.is_string() {\n                return Err(format!(\"metadata field '{}' must be a string\", key));\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_valid_worldpayxml_metadata(v: &serde_json::Value) -> bool {\n    serde_json::from_value::<WorldpayxmlMetadata>(v.clone()).is_ok()\n}","tryCatchPattern":"let meta = metadata\n    .map(|m| serde_json::from_value::<WorldpayxmlMetadata>(m.clone()))\n    .transpose()\n    .map_err(|e| report!(WorldpayxmlMetadataError::InvalidFormat).attach_printable(format!(\"metadata rejected: {}\", e)))?;","preventionTips":["Validate the metadata JSON against WorldpayxmlMetadata (e.g. in tests or a pre-submit check) before saving a merchant connector account.","Always send metadata as a nested JSON object, never as a JSON-encoded string.","Keep string fields as strings even when they look numeric (issuer_id).","Version-control your connector account payloads so schema changes between Hyperswitch upgrades are caught.","Log the serde error (don't discard it with map_err(|_| ...)) in your own wrapper to speed up debugging."],"tags":["serde","metadata","worldpayxml","configuration","deserialization"],"backgroundTag":"schema-validation-failed","analyzedSha":"3093f22cc46b46415cca152ea0b234277b251ecd","analyzedAt":"2026-09-09T12:35:17.659Z","contentChangedAt":"2026-09-09T12:35:17.659Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}