fix: migrate achievements to projectsV2 and guard null commit arrays (activity, habits)#1834
Open
ShawnXxy wants to merge 2 commits into
Open
fix: migrate achievements to projectsV2 and guard null commit arrays (activity, habits)#1834ShawnXxy wants to merge 2 commits into
ShawnXxy wants to merge 2 commits into
Conversation
…ll commit arrays Three independent failures each render an "Unexpected error" box on the profile: - achievements: the query used the sunset `user.projects` (Projects classic) connection, which now resolves to NOT_FOUND and nulls the entire user object. Migrated to `projectsV2`. Fixes lowlighter#1706. - activity: `PushEvent` payloads may omit `commits`; `commits.filter` then throws. Default to `[]`. - habits: same missing-`commits` case in the commit flatMap. Default to `[]`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Several event handlers in the activity plugin deep-destructure a nested
`user: {login}` (or `member: {login}`) directly from the GitHub event
payload. When an actor account has been deleted, the payload's nested
`user`/`member` object is undefined, so reading `.login` throws
`TypeError: Cannot read properties of undefined (reading 'login')`.
Because this throws inside the events `.map`, the entire "Recent activity"
section fails and renders "Unexpected error".
Add an early `return null` guard (skip the single malformed event) to
CommitCommentEvent, IssueCommentEvent, IssuesEvent, MemberEvent,
PullRequestEvent, PullRequestReviewEvent and PullRequestReviewCommentEvent.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three plugins currently render a red "Unexpected error" box on generated metrics, even though the action run reports success. All three fail during rendering with the errors below (captured from a live run):
Root causes & fixes
1.
achievements— Projects (classic) deprecation (fixes #1706)The
AchievementsDefaultquery requestsuser.projects(Projects classic), which GitHub has sunset. The GraphQL API now returns aNOT_FOUNDresponse error for that field, which nulls the entireuserobject and makes the whole plugin throw.Fix: query
projectsV2instead for the "Manager" achievement (achievements.graphql+list/users.mjs).2 & 3.
activity/habits—PushEventwith nocommitsGitHub's Events API can return a
PushEventwhosepayloadhas nocommitsarray.activitythen calls.filteronundefined, andhabitsflat-mapsundefinedinto the patch loader and destructuresauthorfrom it — both throw.Fix: default the missing array to
[]in both plugins.Changes
source/plugins/achievements/queries/achievements.graphql—projects→projectsV2source/plugins/achievements/list/users.mjs—user.projects→user.projectsV2source/plugins/activity/index.mjs—commits = (commits ?? []).filter(...)source/plugins/habits/index.mjs—.flatMap(({payload}) => payload.commits ?? [])Notes
projectsV2reads require theread:project/projecttoken scope (already present for tokens that render this plugin).