Skip to content

fix: migrate achievements to projectsV2 and guard null commit arrays (activity, habits)#1834

Open
ShawnXxy wants to merge 2 commits into
lowlighter:masterfrom
ShawnXxy:fix/deprecated-projects-and-null-guards
Open

fix: migrate achievements to projectsV2 and guard null commit arrays (activity, habits)#1834
ShawnXxy wants to merge 2 commits into
lowlighter:masterfrom
ShawnXxy:fix/deprecated-projects-and-null-guards

Conversation

@ShawnXxy

@ShawnXxy ShawnXxy commented Jul 2, 2026

Copy link
Copy Markdown

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):

{ name: 'achievements', result: { error: {
  message: 'Unexpected error',
  instance: GraphqlResponseError: ... Projects (classic) is being deprecated ...
  response: { data: { user: null }, errors: [ { type: 'NOT_FOUND', path: ['user','projects'] } ] } } } }

{ name: 'activity', result: { error: {
  message: 'Unexpected error',
  instance: TypeError: Cannot read properties of undefined (reading 'filter')
    at source/plugins/activity/index.mjs:140 } } }

{ name: 'habits', result: { error: {
  message: 'Unexpected error',
  instance: TypeError: Cannot destructure property 'author' of 'undefined' as it is undefined.
    at source/plugins/habits/index.mjs:51 } } }

Root causes & fixes

1. achievements — Projects (classic) deprecation (fixes #1706)

The AchievementsDefault query requests user.projects (Projects classic), which GitHub has sunset. The GraphQL API now returns a NOT_FOUND response error for that field, which nulls the entire user object and makes the whole plugin throw.

Fix: query projectsV2 instead for the "Manager" achievement (achievements.graphql + list/users.mjs).

2 & 3. activity / habitsPushEvent with no commits

GitHub's Events API can return a PushEvent whose payload has no commits array. activity then calls .filter on undefined, and habits flat-maps undefined into the patch loader and destructures author from it — both throw.

Fix: default the missing array to [] in both plugins.

Changes

  • source/plugins/achievements/queries/achievements.graphqlprojectsprojectsV2
  • source/plugins/achievements/list/users.mjsuser.projectsuser.projectsV2
  • source/plugins/activity/index.mjscommits = (commits ?? []).filter(...)
  • source/plugins/habits/index.mjs.flatMap(({payload}) => payload.commits ?? [])

Notes

  • projectsV2 reads require the read:project / project token scope (already present for tokens that render this plugin).
  • Verified on a live profile: the three "Unexpected error" boxes are gone and the sections render normally.

ShawnXxy and others added 2 commits July 2, 2026 16:35
…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>
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.

"Manager" Achievement Broken Due to Projects Classic Deprecation

1 participant