juspay/hyperswitch · warning
webhook reference id should be derived
Error message
webhook reference id should be derived
What it means
Test calls `get_webhook_object_reference_id(&request).expect("webhook reference id should be derived")`; a panic means the connector could not extract a reference id (e.g. RefundId) from the webhook body, returning Err.
Solutions
- Update get_webhook_object_reference_id to parse the id from the new payload shape/resource type
- Fix the test fixture so the expected id field (e.g. ID000) is present at the path the parser reads
- Replace expect with unwrap_or_else to log the underlying error
Example fix
// before
.expect("webhook reference id should be derived");
// after
.unwrap_or_else(|e| panic!("webhook reference id should be derived: {e:?}")); Defensive patterns
Strategy: try-catch
Validate before calling
assert!(body.contains("ID000"), "fixture must contain the expected reference id"); Type guard
fn reference_extractable(body: &str) -> bool {
serde_json::from_str::<GocardlessWebhookBody>(body).map(|p| p.reference_id().is_some()).unwrap_or(false)
} Try / catch
get_webhook_object_reference_id(&request).unwrap_or_else(|e| panic!("webhook reference id should be derived: {e:?}")) Prevention
- Keep fixture ids at the JSON path the parser reads
- Add parse-error context to expects in connector tests
When it happens
Trigger: A GoCardless webhook payload missing the id field the parser expects (or an unhandled resource type) makes get_webhook_object_reference_id return Err.
Common situations: Fixture bodies with a renamed/absent `links.refund` style id, or new GoCardless resource types added to tests without updating the reference-id extraction.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- webhook event type should be derived
- a captured response must reconstruct
- authenticated redis settings failed validation
- failed to build the test response
- todo!()
AI-assisted analysis of juspay/hyperswitch@afd9284352 (2026-09-18).
Data as JSON: /api/errors/75086a464da0761e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/hyperswitch_connectors/src/connectors/gocardless.rs:1058
IncomingWebhookEvent::EventNotSupported
);
}
#[test]
fn refund_webhook_references_the_refund() {
let body = webhook_body("refunds", "failed", "refund");
let headers = actix_web::http::header::HeaderMap::new();
let request = IncomingWebhookRequestDetails {
method: http::Method::POST,
uri: http::Uri::from_static("/webhooks"),
headers: &headers,
body: &body,
query_params: String::new(),
};
let reference_id = Gocardless::new()
.get_webhook_object_reference_id(&request)
.expect("webhook reference id should be derived");
assert!(matches!(
reference_id,
ObjectReferenceId::RefundId(RefundIdType::ConnectorRefundId(ref id)) if id == "ID000"
));
}
}
View on GitHub (pinned to afd9284352)