-
Notifications
You must be signed in to change notification settings - Fork 599
getThreadHistory: Filter out messages containing error attachments #360
Conversation
Thanks for taking a look at this issue. I'm not totally sure how this solves any problems, were you able to replicate the problem in #357? I had thought the exception was being thrown from formatMessage. In an ideal world would it be nicer if we could just format these errors like we do in listen? |
Yes, I do get the same messages with error attachments.
The exception is thrown from _formatAttachment because it doesn't handle
attach_type=error. The PR fixes that by handling this type of attachment
and formatting it, while saving the original attachment(s). As far as I've
tested, the original attachment doesn't contain any useful information
about the error, but I thought it might be a good idea to save them just in
case this changes or behaves differently on other accounts.
The PR also filters out messages that contain error attachments, so they
don't get returned in the result of getThreadHistory. If you want me, I can
leave getThreadHistory as it is, so that it returns everything including
messages with error attachments.
|
Oh I see now. Thanks for clarifying! |
Are there a way of suppressing the warnings thrown? |
@AlexGustafsson Yeah, you can set the log level to one higher than "warn", i.e. "error" or "silent". api.setOptions({ logLevel: "error" }); See api.setOptions for more info. @Schmavery @bsansouci Do you think the "warn" level is appropriate for these messages? Should we use something lower, e.g. "info"? |
Warn seems fine to me. |
type: "error", | ||
|
||
// Save error attachments because we're unsure of their format, | ||
// and whether there are cases they contain something useful for debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do errors really not have a specific format? Did you encounter those in the wild? If you would you mind sharing the shape of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsansouci I encounter a few of them in a group chat with ~40k messages. So far, I've only come across error attachments that seem to be empty:
attachment1: { attach_type: 'error' }
attachment2: { id: '', image_data: {} }
However, I'm not sure if there are cases they contain useful information.
@ivkos Hey, thanks for the PR. Supporting the |
Thanks! |
getThreadHistory: Filter out messages containing error attachments
Fixes #357