fix(languages/analyzer): TypeError on null committer#21
fix(languages/analyzer): TypeError on null committer#21ferferga wants to merge 1 commit intogh-metrics:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the languages “recently-used” analyzer when processing PushEvent commit entries that are undefined or have missing committer data.
Changes:
- Hardened PushEvent commit filtering to avoid destructuring
committerfrom anundefinedcommit. - Added an explicit guard for
commit.committer.emailbefore applying the authoring filter.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| commits | ||
| .flatMap(({payload}) => payload.commits) | ||
| .filter(({committer}) => filters.text(committer?.email, this.authoring, {debug: false})) | ||
| .filter(commit => commit?.committer?.email && filters.text(commit.committer.email, this.authoring, {debug: false})) |
There was a problem hiding this comment.
The new filter still uses filters.text(...), which returns true when the value is not in the patterns list. Given commits_authoring is documented/used elsewhere as the set of identifiers to match (e.g., code plugin filters commits where author matches an entry), this likely inverts the intent and can exclude the user’s own commits when commit.committer.email is present. Consider aligning with the other commit-authoring filters by treating commits_authoring as an inclusion match (or explicitly negating filters.text if you want exact-match semantics).
| .filter(commit => commit?.committer?.email && filters.text(commit.committer.email, this.authoring, {debug: false})) | |
| .filter(commit => commit?.committer?.email && !filters.text(commit.committer.email, this.authoring, {debug: false})) |
| commits | ||
| .flatMap(({payload}) => payload.commits) | ||
| .filter(({committer}) => filters.text(committer?.email, this.authoring, {debug: false})) | ||
| .filter(commit => commit?.committer?.email && filters.text(commit.committer.email, this.authoring, {debug: false})) |
There was a problem hiding this comment.
This fixes a runtime TypeError for malformed PushEvent commit entries, but there’s no automated coverage for the specific edge case (e.g., payload.commits containing undefined/null or commits missing committer). Since there is an existing languages plugin test case for the “recently-used” section, consider extending the GitHub activity mock to include such an entry so the regression is caught.
Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
0d638c8 to
441b468
Compare
|
Are they really forcing copilot reviews on everybody these days? That sucks. This looks fine but there's like 20 equivalent PRs in the lowlighter repo and I want to attribute it correctly. |
|
Oops, kwoning it was unmaintained, I didn't even bother checking the original repo. I will leave the related PRs listed here for reference to future people coming across this thread, feel free to add more @lishaduck. I will also edit this comment if I find more |
Nah, you're good! I just keep directing people over there to file over here so I'd feel bad not giving them credit. |
First of all, thank you very much for trying to keep this project active.
In the old version (and in this one), I'm receiving this error at the rendering stage:
This pull request fixes the issue.