github-community-projects / github-community-projects/safe-settings
"appendToResults" brokes when receives undefined in param "res"
- Dominant language
- JavaScript
- Stars
- 921
- Forks
- 226
- Avg merge
- 18h 3m
- Merged PRs (30d)
- 14
Description
We facing an issue with dry-run mode when all times when the repository plugin returns an undefined value, the function appendToResults is broken because the command flat of javascript could not be applied in an undefined value or value different of an array.
Line that brokes
https://github.com/github/safe-settings/blob/f5cde668fe624f9eaf370c8f16cc3084afd7b21f/lib/settings.js#L227
I can write the correction and open one PR, but I opening this issue to check with you folks if it makes sense.
One simple solution is one check if the value passed in appendToResults is an array, basically.
Evidence:
```
TypeError: Cannot read property 'flat' of undefined at Settings.appendToResults (/opt/safe-settings/lib/settings.js:666:46) at /opt/safe-settings/lib/settings.js:227:16 at runNextTicks (internal/process/task_queues.js:60:5) at listOnTimeout (internal/timers.js:526:9) at processTimers (internal/timers.js:500:7) at async Promise.all (index 256) at async Function.syncSubOrgs (/opt/safe-settings/lib/settings.js:21:5) at async Promise.all (index 0) at async Promise.all (index 0) at async middleware (/opt/safe-settings/node_modules/@octokit/webhooks/dist-node/index.js:355:5)
--
```
Contributor guide
Assessment
This issue has not been assessed yet.