Skip to content

Ensure 'body' of response is of type 'bytes'

Neill Whillans requested to merge neill/s3_parser_issue into master

Before raising this MR, consider whether the following are required, and complete if so:

  • Unit tests
  • Metrics
  • Documentation update(s)

If not required, please explain in brief why not.

Description

This request aims to fix the following, occasional TypeError that occurred when parsing a response in _curl_multi_run():

  File "/bb/bin/package/b/buildgrid/0.0.43+b20220909T15442971.amd64/libexec/buildgrid/python/lib/python3.8/site-packages/buildgrid/server/s3/s3utils.py", line 350, in start_multipart_upload
    _curl_multi_run([s3object], curl_handle_func)
  File "/bb/bin/package/b/buildgrid/0.0.43+b20220909T15442971.amd64/libexec/buildgrid/python/lib/python3.8/site-packages/buildgrid/server/s3/s3utils.py", line 254, in _curl_multi_run
    parsed_response = parser.parse(response, None)
  File "/bb/bin/package/b/buildgrid/0.0.43+b20220909T15442971.amd64/libexec/buildgrid/python/lib/python3.8/site-packages/botocore/parsers.py", line 236, in parse
    if self._is_generic_error_response(response):
  File "/bb/bin/package/b/buildgrid/0.0.43+b20220909T15442971.amd64/libexec/buildgrid/python/lib/python3.8/site-packages/botocore/parsers.py", line 284, in _is_generic_error_response
    return body.startswith(b'<html>') or not body
TypeError: startswith first arg must be str or a tuple of str, not bytes

Changes proposed in this merge request:

  • Make the "" case of body in response be of type 'bytes'
Edited by Neill Whillans

Merge request reports