Skip to content

Commit

Permalink
fix(gensupport): cover ChunkRetryDeadline edge case (#1430)
Browse files Browse the repository at this point in the history
Fix an edge case that I noticed when testing a very small
ChunkRetryDeadline via the storage client. If the user
chooses a deadline too short to send a single request for the
chunk, we cause a failure so that resp and err are not
both nil.
  • Loading branch information
tritone authored Feb 9, 2022
1 parent 331bc9e commit ef89845
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/gensupport/resumable.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
}
return nil, err
}
// This case is very unlikely but possible only if rx.ChunkRetryDeadline is
// set to a very small value, in which case no requests will be sent before
// the deadline. Return an error to avoid causing a panic.
if resp == nil {
return nil, fmt.Errorf("upload request to %v not sent, choose larger value for ChunkRetryDealine", rx.URI)
}
return resp, nil
}
// Configure retryable error criteria.
Expand Down

0 comments on commit ef89845

Please sign in to comment.