Skip to content

Commit ef89845

Browse files
authored
fix(gensupport): cover ChunkRetryDeadline edge case (#1430)
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.
1 parent 331bc9e commit ef89845

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/gensupport/resumable.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
155155
}
156156
return nil, err
157157
}
158+
// This case is very unlikely but possible only if rx.ChunkRetryDeadline is
159+
// set to a very small value, in which case no requests will be sent before
160+
// the deadline. Return an error to avoid causing a panic.
161+
if resp == nil {
162+
return nil, fmt.Errorf("upload request to %v not sent, choose larger value for ChunkRetryDealine", rx.URI)
163+
}
158164
return resp, nil
159165
}
160166
// Configure retryable error criteria.

0 commit comments

Comments
 (0)