Skip to content

Fix: Migrate Achievements plugin to Projects V2 API and improve Habits plugin error handling#1769

Open
dkhokhlov wants to merge 6 commits intolowlighter:masterfrom
dkhokhlov:master
Open

Fix: Migrate Achievements plugin to Projects V2 API and improve Habits plugin error handling#1769
dkhokhlov wants to merge 6 commits intolowlighter:masterfrom
dkhokhlov:master

Conversation

@dkhokhlov
Copy link
Copy Markdown

@dkhokhlov dkhokhlov commented Nov 28, 2025

Fix: Migrate Achievements plugin to Projects V2 API and improve Habits plugin error handling

Problem

  1. Achievements plugin was failing with "Unexpected error" due to GitHub deprecating Projects (classic) API. The plugin was querying projects field which is no longer available.
  2. Habits plugin was throwing "Cannot destructure property 'author' of 'undefined'" errors when processing commits that lacked proper structure or had missing author properties.

Solution

Achievements Plugin (Projects V2 Migration)

  • Updated GraphQL queries (achievements.graphql, organizations.graphql) to use projectsV2 instead of deprecated projects field
  • Updated JavaScript handlers (users.mjs, organizations.mjs) to reference projectsV2.totalCount and projectsV2.nodes
  • Maintains backward compatibility with existing achievement logic

Habits Plugin (Defensive Programming)

  • Added type checking to ensure commits are valid objects before processing: commit != null && typeof commit === 'object'
  • Replaced destructuring with safe property access using optional chaining (commit?.author)
  • Prevents runtime errors when GitHub API returns malformed commit data

Docker Build Optimization (Forks)

  • Optimized Dockerfile for forks to use pre-built base image (ghcr.io/lowlighter/metrics:v3.35-beta)
  • Only copies modified source files instead of rebuilding entire image
  • Significantly faster build times for forks while maintaining compatibility

Testing

  • ✅ Achievements plugin now successfully generates SVG output
  • ✅ Habits plugin handles edge cases gracefully without errors
  • ✅ All existing functionality preserved

Fixes #1706, #1739

@lishaduck
Copy link
Copy Markdown

I've been pretty busy IRL recently so I haven't had the chance to pull in all these PRs hanging around into @gh-metrics, but if you'd be willing to go file it over there I'll try to find some time pull it in next week ❤️

- Use original lowlighter/metrics Docker image as base
- Only copy changed GraphQL/JS files (4 files)
- Avoids rebuilding Chrome, Node modules, dependencies
- Much faster builds for code-only changes
- Filter out null/undefined commits from payload.commits
- Add safety check for missing author property
- Prevents 'Cannot destructure property author of undefined' error
@datareccer
Copy link
Copy Markdown

Request pull

@JustJoostNL
Copy link
Copy Markdown

Any update on this? 🙂

@dkhokhlov
Copy link
Copy Markdown
Author

meanwhile you could switch to this PR branch (fork of this repo):

uses: dkhokhlov/metrics@master

https://github.com/dkhokhlov/dkhokhlov/blob/main/.github/workflows/actions.yml#L21

artik0din added a commit to artik0din/artik0din that referenced this pull request Jan 11, 2026
The achievements plugin uses the deprecated Projects Classic API which
GitHub removed in May 2024. This causes a GraphQL error:
"Projects (classic) is being deprecated in favor of the new Projects experience"

The plugin code queries the Projects Classic API even before filtering
out ignored achievements like 'organizer', so there's no workaround.

Open issue: lowlighter/metrics#1706
Fix in progress: lowlighter/metrics#1769

The step is commented out with a TODO to re-enable once PR #1769 is merged.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0x07cf-dev added a commit to 0x07cf-dev/0x07cf-dev that referenced this pull request Jan 29, 2026
Due to breaking changes in the GitHub API, this feature currently does not work. Waiting for this PR: lowlighter/metrics#1769
0x07cf-dev added a commit to 0x07cf-dev/0x07cf-dev that referenced this pull request Jan 29, 2026
* ci: add more metrics

* ci: remove coding habits plugin

Due to breaking changes in the GitHub API, this feature currently does not work. Waiting for this PR: lowlighter/metrics#1769

* ci: add ignored languages
0x07cf-dev added a commit to 0x07cf-dev/0x07cf-dev that referenced this pull request Jan 29, 2026
* ci: add more metrics

* ci: remove coding habits plugin

Due to breaking changes in the GitHub API, this feature currently does not work. Waiting for this PR: lowlighter/metrics#1769

* ci: add ignored languages

* ci: render profile metrics in the repo instead of Gist
LarsArtmann added a commit to LarsArtmann/LarsArtmann that referenced this pull request May 2, 2026
GitHub deprecated Projects (classic) API, causing the achievements
plugin's GraphQL query to fail with "Unexpected error". Switch to
dkhokhlov/metrics fork which migrates to Projects V2 API.

Refs: lowlighter/metrics#1706, lowlighter/metrics#1769

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
LarsArtmann added a commit to LarsArtmann/LarsArtmann that referenced this pull request May 2, 2026
Full retrospective of today's session covering:

DONE:
- Fixed achievements "Unexpected error" (Projects V2 migration)
- Fixed trophies rendering (dead kannan fork → in-workflow SVG gen)
- Updated featured projects to user's current favorites
- End-to-end workflow verified: all 3 SVGs generated and committed

ISSUES FOUND:
- Actions not pinned to SHAs (supply chain risk)
- Workflow self-triggers on push (no [Skip GitHub Action] guard)
- Trophy action ignores `file` input (workaround: cp)
- Project AGENTS.md outdated (v4.1 vs global v5.0)

TOP PRIORITIES:
1. Pin all actions to commit SHAs
2. Add [Skip GitHub Action] guard or remove push trigger
3. Sync/remove stale project AGENTS.md
4. Add typespec-asyncapi (12 stars) to featured projects
5. Check if lowlighter/metrics#1769 merged for fork revert

OPEN QUESTION: Is dkhokhlov/metrics fork permanent or temporary?
Depends on whether upstream PR #1769 merges.

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Manager" Achievement Broken Due to Projects Classic Deprecation

4 participants