Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: coerce arrays when extracting #17997

Merged
merged 4 commits into from Oct 3, 2022
Merged

fix: coerce arrays when extracting #17997

merged 4 commits into from Oct 3, 2022

Conversation

rarkins
Copy link
Collaborator

@rarkins rarkins commented Sep 27, 2022

Changes

Defensively coerces arrays during package manager extract.

Context

Defends against "not iterable" errors we see in production sometimes.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

lib/util/array.ts Outdated Show resolved Hide resolved
lib/util/array.ts Outdated Show resolved Hide resolved
rarkins and others added 2 commits September 27, 2022 17:11
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@rarkins rarkins enabled auto-merge (squash) October 3, 2022 07:09
@rarkins rarkins merged commit e912f89 into main Oct 3, 2022
@rarkins rarkins deleted the fix/coerce-array branch October 3, 2022 07:20
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 32.213.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

import is from '@sindresorhus/is';

export function coerceArray<T>(input: T[] | null | undefined): T[] {
if (is.array(input)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add another check for non-array type and log a debug message when it's not null or undefined.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants