Skip to content

Conversation

@oddstr13
Copy link

@oddstr13 oddstr13 commented Oct 17, 2025

⚠️ This is a working branch, and not intended for direct merging.
It is provided for discussion and community visibility. The quality of this code is not suitable for merging as-is.


This PR fixes the following error causing failure to update svg and failed action runs;

 file:///metrics/source/app/action/index.mjs:15
  throw error
  ^

TypeError: Cannot destructure property 'committer' of 'undefined' as it is undefined.
    at file:///metrics/source/plugins/languages/analyzer/recent.mjs:70:21
    at Array.filter (<anonymous>)
    at RecentAnalyzer.patches (file:///metrics/source/plugins/languages/analyzer/recent.mjs:70:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RecentAnalyzer.analyze (file:///metrics/source/plugins/languages/analyzer/recent.mjs:25:21)
    at async file:///metrics/source/plugins/languages/analyzer/recent.mjs:19:7
    at async results (file:///metrics/source/plugins/languages/analyzer/analyzer.mjs:63:7)

GitHub recently changed the APIs used to get some of the commit information used in the recent languages portion of the code. API version was not bumped, and the breaking changes documentation was not updated, so it took me a while to figure out what had gone wrong. Once I did, however, I found this blog post that hints at what they where doing and why; https://github.blog/changelog/2025-08-08-upcoming-changes-to-github-events-api-payloads/

Specifically, this part of the PushEvent no longer exists:

commits: [
{
sha: "MOCKED_SHA",
message: faker.lorem.sentence(),
url: "https://api.github.com/repos/lowlighter/metrics/commits/MOCKED_SHA",
author: {
email: faker.internet.email(),
},
},
],

I'm not familiar with the code base, nor particularly familiar with the code style (additionally, auto-formatter managed to sneak in some whitespace – ignore that.), so the implementation may not be the best. I'm fairly certain that I managed to re-implement it properly however.

Do note the change from using committer to author in the authored by message, as committer would be GitHub for any file edited in the web interface (but set to the appropriate info in the authored structure). Not sure if that string is used anywhere, but that seemed more correct.

I am trying to do some smarts here in how many pages of commits we retrieve, based on the commits the event listed as head and base (we could use those two fields to get the patch of the changeset, but then we couldn't filter author on a commit-by-commit basis gh api -H "Accept: application/vnd.github.patch" /repos/oddstr13/github-profile-metrics/compare/c32878ca41906dba3e10fc9f19b2b12bc4298cd8...de58e40391d57e531a9e7330f7935d3637f85efd).

This branch contain unrelated changes, mainly in the dockerfile, as this is my testing branch (and what is currently used to update my profile badge).


Closes #1753 as it only hides the exception

#1739 is related, in that it seems to be hiding the same issue in a different part of the code base, I have not looked into this yet, but that PR doesn't fix the underlying issue either, just hides it

@oddstr13 oddstr13 changed the title WIP: Fix recent languages after GitHub API change () WIP: Fix recent languages after GitHub API change (Cannot destructure property 'committer' of 'undefined') Oct 17, 2025
@fbuireu
Copy link

fbuireu commented Oct 22, 2025

Any updates on this? I'm also having the same issue @lowlighter

@oddstr13
Copy link
Author

It is functional but not suited for merging as-is, and I haven't looked into the other parts of the code also broken by this API change.

You can see my config here for how to use this branch;
https://github.com/oddstr13/oddstr13/blob/a623f10b5933d3a011d7c2d210119c2cdb770f35/.github/workflows/metrics.yaml#L16-L18

I would advice pinning to specific commit rather than my workbranch.

It runs much slower than the pre-compiled version, as it compiles the whole thing each time.

lowlighter has stated on their profile that this project is currently on the backburner, so I wouldn't expect a speedy response from them.

I don't have time right now to work more on this, but with the changes I've done so far, the recent languages functionality is back, and the workflow is no longer crashing with my particular configuration, tho it is throwing (non-fatal) errors in other modules (such as the recent coding habbits – not rendering anything, but also not failing the workflow).

@lishaduck
Copy link

Any updates on this? I'm also having the same issue @lowlighter

lowlighter has stated on their profile that this project is currently on the backburner, so I wouldn't expect a speedy response from them.

Yup. It's a bit of a shame, but I've resorted to forking under @gh-metrics.

I would advice pinning to specific commit rather than my workbranch.

(Same for the @gh-metrics, haven't set up tagging, it's still pretty YOLO for now)

It is functional but not suited for merging as-is, and I haven't looked into the other parts of the code also broken by this API change.

If you want to send a PR over to @gh-metrics, I'd be game to work on getting it fixed.

It runs much slower than the pre-compiled version, as it compiles the whole thing each time.

I clearly haven't looked closely enough at v3 (mostly was messing around with v4 back when I forked)
It's compiled? Isn't it JS? Or do you just mean the that docker's really messed up.

@oddstr13
Copy link
Author

I might look into sending you a pr at some point, but I'm likely not going to give it top priority.

Yes, it is JavaScript, but it is also compiled (or, more specifically, transpiled - most non-vanilla-browser-js is).
In addition, we need non-javascript dependencies too, such as chrome and other packages on top of debian.
As it is on my fork right now, the whole environment is re-built each time (the docker container), while when I was using upstream, a versioned docker container was pre-built and downloaded instead. This resulted in workflow run times of around 10s before failing, vs about 2min for when building from source (iirc, ballpark numbers from memory).

Feel free to cherry-pick commits if I don't get around to making a PR within a reasonable time, if you're comfortable with the more advanced parts of the git workflow. This PR was intended as a "I fixed it, here's how I did it – but there is more to be done". Just make sure git attribution is proper.

@lishaduck
Copy link

I might look into sending you a pr at some point, but I'm likely not going to give it top priority.

Feel free to cherry-pick commits if I don't get around to making a PR within a reasonable time, if you're comfortable with the more advanced parts of the git workflow. This PR was intended as a "I fixed it, here's how I did it – but there is more to be done".

I'm certainly not asking you to PR if you don't want to, I just didn't to CP your PR if you'd prefer to do it yourself (I know some people can be picky about that).

Just make sure git attribution is proper.

ofc!

Yes, it is JavaScript, but it is also compiled (or, more specifically, transpiled - most non-vanilla-browser-js is). In addition, we need non-javascript dependencies too, such as chrome and other packages on top of debian. As it is on my fork right now, the whole environment is re-built each time (the docker container), while when I was using upstream, a versioned docker container was pre-built and downloaded instead. This resulted in workflow run times of around 10s before failing, vs about 2min for when building from source (iirc, ballpark numbers from memory).

Is it transpiled? I don't transpiler installed anywhere but maybe I'm just being blind.

But yeah, the Docker's messed up. I'm thinking about probably making a CP of #1724 too and seeing if that helps.


And thanks for all your hard work!

hxreborn added a commit to hxreborn/metrics that referenced this pull request Oct 31, 2025
Uses exact implementation from oddstr13's PR lowlighter#1754:
- Builds wanted map with repo@ref keys
- Fetches commits via REST API directly
- Tracks before/head SHAs for early exit
- Uses optional chaining to prevent destructuring errors
- Fetches full commit details with file patches
hxreborn added a commit to hxreborn/metrics that referenced this pull request Oct 31, 2025
Implements PR lowlighter#1754 fix using direct REST API commit fetching:
- GitHub Events API removed commit details from push payloads (Aug 2025)
- Uses REST API endpoints to fetch commits directly per repo/branch
- Builds wanted map for selective commit fetching with early exit
- Filters commits by authoring email safely using optional chaining
- Fetches full commit details with file patches for language analysis
- Verified working with multiple languages across repositories
hxreborn added a commit to hxreborn/metrics that referenced this pull request Oct 31, 2025
Implements PR lowlighter#1754 fix using direct REST API commit fetching:
- GitHub Events API removed commit details from push payloads (Aug 2025)
- Uses REST API endpoints to fetch commits directly per repo/branch
- Builds wanted map for selective commit fetching with early exit
- Filters commits by authoring email safely using optional chaining
- Fetches full commit details with file patches for language analysis
- Verified working with multiple languages across repositories
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.

3 participants