Skip to content

Conversation

@Simplyalex99
Copy link
Contributor

@Simplyalex99 Simplyalex99 commented Jul 5, 2025

Summary

Switched from fetchStarterMessage to just fetching the first message in the thread and checking for any attachments or content before sending a bot response. In addition, added a retry in case of race conditions. Also removed colon from print statement for better readability.

Issue

The error Cannot read properties of undefined (reading 'parent') originated from fetchStarterMessage when a forum post is made.

Solution

However, after care analysis, the fetchStarterMessage seems to only apply for non-forum channels as forums are different and do not have a parent id post, unlike normal threads when tested in development. For this reason, the fetchStarterMessage was removed for now.

@Simplyalex99 Simplyalex99 requested a review from vcarl July 5, 2025 16:14
@kristersd
Copy link
Contributor

The error Cannot read properties of undefined (reading 'parent') originated from fetchStarterMessage when a forum post only contains an image and no description.

The issue happens on each new post and is not exclusive to messages without description. Have you managed to reproduce the issue in testing server?

@Simplyalex99
Copy link
Contributor Author

Simplyalex99 commented Jul 7, 2025

The error Cannot read properties of undefined (reading 'parent') originated from fetchStarterMessage when a forum post only contains an image and no description.

The issue happens on each new post and is not exclusive to messages without description. Have you managed to reproduce the issue in testing server?

Yes, in the test server fetchStarterMessage throws an error since forums don't count as having a parent message. This method only works for non-forum channels. The solution I proposed fixes this.

@kristersd
Copy link
Contributor

Your Issue in the merge request description mentions the issue only happens, when a forum post only contains an image and no description. Could you please update it?

@Simplyalex99
Copy link
Contributor Author

Simplyalex99 commented Jul 7, 2025

Updated! And apologies, I couldn't replicate the issue of an error on every post on production a couple days ago but now I am seeing it for every post on bot log. The issue reproduction I wrote was a case that caused this to happen on both local and production when I first tried it, but I did get an error for every forum post locally, just I couldn't make it happen on production, so wasn't sure.

@kristersd
Copy link
Contributor

kristersd commented Jul 7, 2025

I think the issue is with the way we are using retry. We should be providing callback instead of directly calling retry(thread.fetchStarterMessage). The way currently we have setup it would lose this ctx to the ThreadChannel class and reference retry function scope.

- await retry(thread.fetchStarterMessage);
+ await retry(() => thread.fetchStarterMessage());

@Simplyalex99
Copy link
Contributor Author

After testing, it does appear to be a context issue of losing this without passing a callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants