-
Notifications
You must be signed in to change notification settings - Fork 41
fix(craft): Wrap upload and craft errors to raise errors #830
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: Javier Rodriguez <javier@chainloop.dev>
| // If there is a max size set and the file is bigger than that, return an error | ||
| if backend.MaxSize > 0 && result.size > backend.MaxSize { | ||
| return nil, fmt.Errorf("this file is too big for the %s CAS backend, please contact your administrator: fileSize=%s, maxSize=%s", backend.Name, bytefmt.ByteSize(uint64(result.size)), bytefmt.ByteSize(uint64(backend.MaxSize))) | ||
| return nil, fmt.Errorf("%w: %w", ErrBaseUploadAndCraft, fmt.Errorf("this file is too big for the %s CAS backend, please contact your administrator: fileSize=%s, maxSize=%s", backend.Name, bytefmt.ByteSize(uint64(result.size)), bytefmt.ByteSize(uint64(backend.MaxSize)))) |
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 would personally use errors.Join(ErrBaseUploadAndCraft, ...) here
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
migmartri
left a comment
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 think the tests need some work. Approved though, thanks!
|
Let met rework on the test cases and the default error :) |
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
migmartri
left a comment
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!
| if tc.exceedSize { | ||
| // Establishing a maximum size for the artifact to be uploaded to the CAS causes an error | ||
| // if the value is exceeded | ||
| if tc.wantErr { |
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.
this is fine for now but whenever we add a string validation this test will not work I think. Either way, that's smth for the future :)
This patch creates a base error for the
uploadAndCraftmethod that can be used to determine errors during the upload of and artifact.This is needed for cases where the incoming material is detected correctly but the error happens when trying to upload it to a CAS.
A part from being added to the debug sequence is returned to the user as follows:
Without --debug:
Refs: #828