From b0c0ea6601330b8e46008f26fe86c42162c82e0f Mon Sep 17 00:00:00 2001 From: Austen Stone Date: Wed, 9 Jul 2025 11:25:08 -0400 Subject: [PATCH] fix: Cannot destructure property 'author' of 'undefined' Fixing error ``` 1 error(s) occurred [ { name: 'habits', result: { error: { message: 'Unexpected error', instance: TypeError: Cannot destructure property 'author' of 'undefined' as it is undefined. at file:///metrics/source/plugins/habits/index.mjs:51:21 } } } ] ``` --- source/plugins/habits/index.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/plugins/habits/index.mjs b/source/plugins/habits/index.mjs index 3a1a437d602..c4b1f2598c4 100644 --- a/source/plugins/habits/index.mjs +++ b/source/plugins/habits/index.mjs @@ -48,8 +48,11 @@ export default async function({login, data, rest, imports, q, account}, {enabled ...await Promise.allSettled( commits .flatMap(({payload}) => payload.commits) - .filter(({author}) => data.shared["commits.authoring"].filter(authoring => author?.login?.toLocaleLowerCase().includes(authoring) || author?.email?.toLocaleLowerCase().includes(authoring) || author?.name?.toLocaleLowerCase().includes(authoring)).length) - .map(async commit => (await rest.request(commit)).data.files), + .filter(commit => commit?.author && data.shared["commits.authoring"].some(authoring => + commit.author.login?.toLocaleLowerCase().includes(authoring) || + commit.author.email?.toLocaleLowerCase().includes(authoring) + )) + .map(async commit => (await rest.request(commit)).data.files), ), ] .filter(({status}) => status === "fulfilled")