Handle detailedAccount null or undefined in gocardless service. Fixes #5664 (#5706)

* fix detailedAccount could be null or undefined

* add release notes
This commit is contained in:
Mauro Artizzu
2025-09-11 15:45:43 +02:00
committed by GitHub
parent d2cfedf5e4
commit 7a420b79f2
2 changed files with 14 additions and 3 deletions

View File

@@ -426,16 +426,21 @@ export const goCardlessService = {
handleGoCardlessError(error);
}
// Handle cases where either response is null/undefined
const accountDetails = detailedAccount?.account || {};
const metadata = metadataAccount || {};
// Some banks provide additional data in both fields, but can do yucky things like have an empty
// string in one place but not the other. We'll fix this by merging the two objects, but preferring truthy values
// from the metadata object over the details object.
const mergedAccount = {};
const uniqueKeys = new Set([
...Object.keys(detailedAccount.account),
...Object.keys(metadataAccount),
...Object.keys(accountDetails),
...Object.keys(metadata),
]);
for (const key of uniqueKeys) {
mergedAccount[key] = metadataAccount[key] || detailedAccount.account[key];
mergedAccount[key] = metadata[key] || accountDetails[key];
}
return mergedAccount;

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [mauroartizzu]
---
Fixes detailedAccounts that might me null or undefined with some Italian Banks (Widiba, Poste, Intesa)