{"record":{"id":"75086a464da0761e","repo":"juspay/hyperswitch","slug":"webhook-reference-id-should-be-derived","errorCode":null,"errorMessage":"webhook reference id should be derived","messagePattern":"webhook reference id should be derived","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/hyperswitch_connectors/src/connectors/gocardless.rs","lineNumber":1058,"sourceCode":"            IncomingWebhookEvent::EventNotSupported\n        );\n    }\n\n    #[test]\n    fn refund_webhook_references_the_refund() {\n        let body = webhook_body(\"refunds\", \"failed\", \"refund\");\n        let headers = actix_web::http::header::HeaderMap::new();\n        let request = IncomingWebhookRequestDetails {\n            method: http::Method::POST,\n            uri: http::Uri::from_static(\"/webhooks\"),\n            headers: &headers,\n            body: &body,\n            query_params: String::new(),\n        };\n\n        let reference_id = Gocardless::new()\n            .get_webhook_object_reference_id(&request)\n            .expect(\"webhook reference id should be derived\");\n\n        assert!(matches!(\n            reference_id,\n            ObjectReferenceId::RefundId(RefundIdType::ConnectorRefundId(ref id)) if id == \"ID000\"\n        ));\n    }\n}\n","sourceCodeStart":1040,"sourceCodeEnd":1066,"githubUrl":"https://github.com/juspay/hyperswitch/blob/afd92843521ced2c6856b98ae4ea332e75102d88/crates/hyperswitch_connectors/src/connectors/gocardless.rs#L1040-L1066","documentation":"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.","triggerScenarios":"A GoCardless webhook payload missing the id field the parser expects (or an unhandled resource type) makes get_webhook_object_reference_id return Err.","commonSituations":"Fixture bodies with a renamed/absent `links.refund` style id, or new GoCardless resource types added to tests without updating the reference-id extraction.","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"],"exampleFix":"// before\n.expect(\"webhook reference id should be derived\");\n// after\n.unwrap_or_else(|e| panic!(\"webhook reference id should be derived: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"assert!(body.contains(\"ID000\"), \"fixture must contain the expected reference id\");","typeGuard":"fn reference_extractable(body: &str) -> bool {\n    serde_json::from_str::<GocardlessWebhookBody>(body).map(|p| p.reference_id().is_some()).unwrap_or(false)\n}","tryCatchPattern":"get_webhook_object_reference_id(&request).unwrap_or_else(|e| panic!(\"webhook reference id should be derived: {e:?}\"))","preventionTips":["Keep fixture ids at the JSON path the parser reads","Add parse-error context to expects in connector tests"],"tags":["rust","tests","webhooks","gocardless"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"afd92843521ced2c6856b98ae4ea332e75102d88","analyzedAt":"2026-09-18T01:18:02.947Z","contentChangedAt":"2026-09-18T01:18:02.947Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}