Repository: ccxt/ccxt
Pull request: base - undefined string in findBroadlyMatchedKey exception
fix #12698
this PR depends on another PR: https://github.com/ccxt/ccxt/pull/14808

Problem statement:
ccxt/base/exchange.py find_broadly_matched_key not catching some exceptions, fix in body
You should add "string = str(string)" to the top of find_broadly_matched_key(self, string, key) in the title file, otherwise an unknown exchange error throwing an exception will crash with "NoneType has no attribute 'find' ". Code is on another computer, sorry for the lack of replicability.

Hints from issue discussion:

Commit message: base - undefined string in broad exceptions

Patch to review:
diff --git a/js/base/Exchange.js b/js/base/Exchange.js
index de32453a8fea5..630fdbb41a5fb 100644
--- a/js/base/Exchange.js
+++ b/js/base/Exchange.js
@@ -2087,8 +2087,10 @@ module.exports = class Exchange {
         const keys = Object.keys (broad);
         for (let i = 0; i < keys.length; i++) {
             const key = keys[i];
-            if (string.indexOf (key) >= 0) {
-                return key;
+            if (string !== undefined && string !== null) { // #issues/12698
+                if (string.indexOf (key) >= 0) {
+                    return key;
+                }
             }
         }
         return undefined;


Code review comments:
diff_hunk: @@ -2087,8 +2087,10 @@ module.exports = class Exchange {
         const keys = Object.keys (broad);
         for (let i = 0; i < keys.length; i++) {
             const key = keys[i];
-            if (string.indexOf (key) >= 0) {
-                return key;
+            if (string !== undefined && string !== null) { // #issues/12698
path: js/base/Exchange.js
text: @user1:
!== null is not transpilable 

@author:
fixed it