From 178dbb9f95835a3e0c7268a6e0e47f3f5302bd23 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:36:12 +0530 Subject: [PATCH] Added debug log for missing post id in embedded permalink (#23790) * Added stricter checks for accessing other post embed data * Added debug log * Removed unused import * lint fix --- .../mattermost-redux/src/reducers/entities/posts.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/posts.ts b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/posts.ts index 3f176e1709..b1e4134695 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/posts.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/posts.ts @@ -218,6 +218,13 @@ export function handlePosts(state: RelationOneToOne = {}, action: Ge const newEmbeds: PostEmbed[] = []; for (const embed of otherPost.metadata.embeds) { + if (embed.type === 'permalink' && embed.data && !('post_id' in embed.data)) { + // eslint-disable-next-line no-console + console.error('post_id missing in post embed data for permalink.'); + // eslint-disable-next-line no-console + console.error(embed.data); + } + if (embed.type === 'permalink' && (embed.data as PostPreviewMetadata).post_id === post.id) { // skip if the embed is the deleted post continue;