fix: handle undefined values when handling results#845
Open
fandasson wants to merge 4 commits intogithub:main-enterprisefrom
Open
fix: handle undefined values when handling results#845fandasson wants to merge 4 commits intogithub:main-enterprisefrom
fandasson wants to merge 4 commits intogithub:main-enterprisefrom
Conversation
Should fix issue github#501
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes issue #501 by adding safeguards to handle undefined values in results and error reporting. The key changes are:
- In lib/settings.js, error actions and change actions are now guarded with default objects to avoid undefined values.
- The result processing logic skips entries without an action property.
- In lib/configManager.js, a safe null return is added after a failed GitHub API call.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/settings.js | Added default values and skipped processing for undefined actions. |
| lib/configManager.js | Enhanced error handling by returning null on fetch failures. |
Comments suppressed due to low confidence (2)
lib/settings.js:206
- The error action is now pushed as an object instead of a string. Please confirm that downstream consumers of stats.errors can handle an object with a msg property rather than a plain string.
stats.errors[res.repo].push(res.action ?? { msg: 'Unknown error' })
lib/settings.js:214
- The changes array now may contain an object with a msg field even if res.action is undefined, replacing a string representation. Verify that any code consuming stats.changes can handle both objects and strings without issues.
stats.changes[res.plugin][res.repo].push(res.action ?? { msg: 'No action details' })
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.
This is patch update handling undefined values in few scenarios I observed when using this tool.
I believe it should fix issue #501. I observed the same freezing in github action and this fixes properly handling undefined fixes it.