-
Notifications
You must be signed in to change notification settings - Fork 38
fix(cli): handle empty files #430
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
Conversation
Signed-off-by: Jose I. Paris <jiparis@gmail.com>
} | ||
|
||
if info.Size() == 0 { | ||
a.Logger.Info().Msg("the file is empty, nothing to upload") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a context question, most likely for @migmartri, but anybody who knows the answer is welcome to reply ofc.
What is the context for these files?
Would someone find legit, in the generic scenario, to produce and upload an empty file?
This implementation is returning here, so client.UploadFile(...)
is not being called at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting point.
I think you are right, it doesn't harm to upload empty files. In fact, artifact material types in attestations can be empty, but this code doesn't affect that (this is only for chainloop artifact upload
cmd.)
The change in uploader.go
is in fact what fixes the original panic #380, so I think it's ok if we remove
if info.Size() == 0 {
a.Logger.Info().Msg("the file is empty, nothing to upload")
...
and just keep the change at internal/casclient/uploader.go
.
What do you think?
Note: This implementation is based on my prescription offline, so any blame is on me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll update the PR with your sugested changes. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok perfect. I'll request changes to remember not to merge this until it's fixed.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Adding some comments to reply to @buccarel
} | ||
|
||
if info.Size() == 0 { | ||
a.Logger.Info().Msg("the file is empty, nothing to upload") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting point.
I think you are right, it doesn't harm to upload empty files. In fact, artifact material types in attestations can be empty, but this code doesn't affect that (this is only for chainloop artifact upload
cmd.)
The change in uploader.go
is in fact what fixes the original panic #380, so I think it's ok if we remove
if info.Size() == 0 {
a.Logger.Info().Msg("the file is empty, nothing to upload")
...
and just keep the change at internal/casclient/uploader.go
.
What do you think?
Note: This implementation is based on my prescription offline, so any blame is on me :)
Signed-off-by: Jose I. Paris <jiparis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for the fix we agreed on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
@buccarel ptal, it seems that the fix is now up. |
Gracefully handle empty files uploads.
Closes #380