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: prevent splitting on an undefined value #247

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

saemik94
Copy link
Contributor

@saemik94 saemik94 commented Jul 18, 2023

Summary

Fixed a bug where the imageList.widget crashed, due to empty digest or tag on docker images.

Proposed Changes

Checklist

@saemik94 saemik94 marked this pull request as ready for review July 18, 2023 21:26

imageList.push([
image.Id.substring(7, 12),
image.RepoDigests ? image.RepoDigests[0].split('@')[0] : getTag(image[2], 0),
(image.RepoDigests && image.RepoDigests.length) ? image.RepoDigests[0].split('@')[0] : getTag(image[2], 0),
Copy link
Contributor Author

@saemik94 saemik94 Jul 18, 2023

Choose a reason for hiding this comment

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

I would prefer to use the chaining operator to check the values, but the linter prevents the use of this operator.

image.RepoDigests && image.RepoDigests.length vs. image.RepoDigests?.length

The dependency "default": "^12.0.1" would need to be updated, the latest version is 17.1.0 and the operator is supported from version 15. But this leads to a whole list of adjustments that would then have to be made. I am not sure how to handle this?

Copy link
Owner

Choose a reason for hiding this comment

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

It's ok to use as-is and skip the optional chaining due to support of older Node.js versions.

@lirantal lirantal self-requested a review July 18, 2023 22:28
@lirantal lirantal added the bug label Jul 18, 2023

imageList.push([
image.Id.substring(7, 12),
image.RepoDigests ? image.RepoDigests[0].split('@')[0] : getTag(image[2], 0),
(image.RepoDigests && image.RepoDigests.length) ? image.RepoDigests[0].split('@')[0] : getTag(image[2], 0),
Copy link
Owner

Choose a reason for hiding this comment

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

It's ok to use as-is and skip the optional chaining due to support of older Node.js versions.

@lirantal
Copy link
Owner

@saemik94 thanks, I'll land this change and it will follow with publishing a new npm version and a new docker image tag to Docker Hub.

Thank you so much! ❤️

@lirantal lirantal merged commit a09177d into lirantal:main Jul 19, 2023
@github-actions
Copy link

🎉 This PR is included in version 3.23.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@saemik94 saemik94 deleted the bugfix/imageList-widget branch August 2, 2023 12:20
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.

2 participants