From 598d40b0b75c50ef1c916b11c8dbac65af5f02ea Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 5 Jul 2017 10:51:08 +0100 Subject: [PATCH] Sanity-check response from /thirdparty/protocols Check that /thirdparty/protocols gives us an object (rather than a string, for instance). I saw a test explode, apparently because it gave us a string. Which is odd, but in general we ought to be sanity-checking the things coming back from the server. --- src/base-apis.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index 35ef0938c82..978e2804ead 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -1326,7 +1326,15 @@ MatrixBaseApis.prototype.getThirdpartyProtocols = function() { return this._http.authedRequestWithPrefix( undefined, "GET", "/thirdparty/protocols", undefined, undefined, httpApi.PREFIX_UNSTABLE, - ); + ).then((response) => { + // sanity check + if (!response || typeof(response) !== 'object') { + throw new Error( + `/thirdparty/protocols did not return an object: ${response}`, + ); + } + return response; + }); }; /**