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

pkg/debuginfo: Better errors in uploads #2113

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions pkg/debuginfo/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@ func (s *Store) Upload(stream debuginfopb.DebugInfoService_UploadServer) error {

func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) error {
if err := validateInput(buildID); err != nil {
err = fmt.Errorf("invalid build ID: %w", err)
return status.Error(codes.InvalidArgument, err.Error())
return status.Error(codes.InvalidArgument, fmt.Errorf("invalid build ID: %w", err).Error())
}

if err := validateInput(hash); err != nil {
err = fmt.Errorf("invalid hash: %w", err)
return status.Error(codes.InvalidArgument, err.Error())
return status.Error(codes.InvalidArgument, fmt.Errorf("invalid hash: %w", err).Error())
}

level.Debug(s.logger).Log("msg", "trying to upload debug info", "buildid", buildID)
Expand Down Expand Up @@ -230,7 +228,7 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
}
level.Error(s.logger).Log("msg", "failed to validate object file", "buildid", buildID)
// Client will retry.
return status.Error(codes.Internal, err.Error())
return status.Error(codes.Internal, fmt.Errorf("validate elf file: %w", err).Error())
}

// Valid.
Expand Down Expand Up @@ -283,12 +281,11 @@ func (s *Store) upload(ctx context.Context, buildID, hash string, r io.Reader) e
err = fmt.Errorf("failed to update metadata after uploaded, as corrupted: %w", err)
return status.Error(codes.Internal, err.Error())
}
return status.Error(codes.InvalidArgument, err.Error())
return status.Error(codes.InvalidArgument, fmt.Errorf("validate elf header: %w", err).Error())
}

if err := s.metadata.MarkAsUploaded(ctx, buildID, hash); err != nil {
err = fmt.Errorf("failed to update metadata after uploaded: %w", err)
return status.Error(codes.Internal, err.Error())
return status.Error(codes.Internal, fmt.Errorf("failed to update metadata after uploaded: %w", err).Error())
}

return nil
Expand Down