You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to blindsidenetworks/mattermost-plugin-bigbluebutton#225 there are malformed posts in my history. I don't expect matterhorn to handle malformed posts correctly, but given that plugins can currently insert malformed posts, I do expect to be able to view other posts even in the presence of such malformed posts.
This probably will need changes in matterhorn-api as well.
I don't have a reduced test-case, but injecting a post with from_webhook set to any non-string value should reproduce the issue readily.
If it's helpful, the errors I get are of the form JSONDecodeException {jsonDecodeExceptionMsg = "Error in $.posts.<id>.props['from_webhook']: parsing Text failed, expected String, but encountered boolean, jsonDecodeExceptionJSON = "{"order":[...]...}"
The text was updated successfully, but these errors were encountered:
My current workaround for this is probably not appropriate for upstreaming, as it only works around the specific issue I encounter; it handles the correct form (string-as-bool) the same way currently, passes a bool through unmolested, and treats any other value as "false". I've included it below in any case.
I suspect the proper fix would involve changing the parsing of the Posts FromJSON to handle malformed posts in some appropriate manner, but my Haskell skills are not up to the task.
diff --git a/src/Network/Mattermost/Types.hs b/src/Network/Mattermost/Types.hs
index de62e65..113aa30 100644
--- a/src/Network/Mattermost/Types.hs
+++ b/src/Network/Mattermost/Types.hs
@@ -711,7 +711,10 @@ instance A.FromJSON PostProps where
postPropsFromWebhookStr <- v .:? "from_webhook"
let postPropsFromWebhook = do
s <- postPropsFromWebhookStr
- return $ s == ("true"::Text)
+ return $ case s of
+ (A.Bool x) -> x
+ (A.String x) -> x == ("true"::Text)
+ _ -> False
postPropsAttachments <- v .:? "attachments"
postPropsNewHeader <- v .:? "new_header"
postPropsOldHeader <- v .:? "old_header"
Due to blindsidenetworks/mattermost-plugin-bigbluebutton#225 there are malformed posts in my history. I don't expect matterhorn to handle malformed posts correctly, but given that plugins can currently insert malformed posts, I do expect to be able to view other posts even in the presence of such malformed posts.
This probably will need changes in matterhorn-api as well.
I don't have a reduced test-case, but injecting a post with from_webhook set to any non-string value should reproduce the issue readily.
If it's helpful, the errors I get are of the form
JSONDecodeException {jsonDecodeExceptionMsg = "Error in $.posts.<id>.props['from_webhook']: parsing Text failed, expected String, but encountered boolean, jsonDecodeExceptionJSON = "{"order":[...]...}"
The text was updated successfully, but these errors were encountered: