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

get_bucket_location returns NoneType error when client error is added #1884

Closed
samhine opened this issue Nov 12, 2019 · 1 comment · Fixed by #1996
Closed

get_bucket_location returns NoneType error when client error is added #1884

samhine opened this issue Nov 12, 2019 · 1 comment · Fixed by #1996
Assignees
Labels
bug This issue is a confirmed bug. s3

Comments

@samhine
Copy link

samhine commented Nov 12, 2019

Problem

When adding a client error through get_bucket_location, rather than raise a ClientError (or the specified Service Error Code, we instead receive;

AttributeError: 'NoneType' object has no attribute 'stream'

Working Example (with get_bucket_logging)

import boto3
from botocore.stub import Stubber

client = boto3.client('s3')
stubber = Stubber(client)
stubber.add_client_error('get_bucket_logging', 'NoSuchBucket')
stubber.activate()

# Raises botocore.errorfactory.NoSuchBucket
client.get_bucket_logging(Bucket="meh")

Non-working Example (with get_bucket_location)

import boto3
from botocore.stub import Stubber

client = boto3.client('s3')
stubber = Stubber(client)
stubber.add_client_error('get_bucket_location', 'NoSuchBucket')
stubber.activate()

# Raises an AttributeError from within awsrequest.py
client.get_bucket_location(Bucket="meh")

The full stack response from this error is;

Traceback (most recent call last):
  File "untitled.py", line 24, in <module>
    client.get_bucket_location(Bucket="meh")
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 655, in _make_api_call
    model=operation_model, context=request_context
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/handlers.py", line 485, in parse_get_bucket_location
    response_body = http_response.content
  File "/usr/local/lib/python3.7/site-packages/botocore/awsrequest.py", line 587, in content
    self._content = bytes().join(self.raw.stream()) or bytes()
AttributeError: 'NoneType' object has no attribute 'stream'

Summary

I've tried searching open/closed issues but can't find something similar, nor a working example online using get_bucket_location. I fear this might be a bug within botocore.stub itself. Any help would be greatly appreciated! Thanks.

@samhine samhine changed the title get_bucket_location returns NoneType eror when client error is added get_bucket_location returns NoneType error when client error is added Nov 12, 2019
@swetashre swetashre self-assigned this Nov 12, 2019
@swetashre swetashre added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Nov 14, 2019
@swetashre
Copy link
Contributor

@samhine - Thank you for your post. I am able to reproduce the issue. I would mark this as bug.

@swetashre swetashre added s3 bug This issue is a confirmed bug. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Nov 15, 2019
gcf-merge-on-green bot pushed a commit to GoogleCloudPlatform/python-docs-samples that referenced this issue Mar 27, 2020
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [boto3](https://togithub.com/boto/boto3) | patch | `==1.12.21` -> `==1.12.30` |

---

### Release Notes

<details>
<summary>boto/boto3</summary>

### [`v1.12.30`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11230)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.29...1.12.30)

=======

-   api-change:`sagemaker`: [``botocore``] Update sagemaker client to latest version
-   api-change:`fsx`: [``botocore``] Update fsx client to latest version
-   api-change:`securityhub`: [``botocore``] Update securityhub client to latest version

### [`v1.12.29`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11229)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.28...1.12.29)

=======

-   api-change:`managedblockchain`: [``botocore``] Update managedblockchain client to latest version
-   api-change:`ce`: [``botocore``] Update ce client to latest version
-   api-change:`application-insights`: [``botocore``] Update application-insights client to latest version
-   api-change:`detective`: [``botocore``] Update detective client to latest version
-   api-change:`es`: [``botocore``] Update es client to latest version
-   api-change:`xray`: [``botocore``] Update xray client to latest version

### [`v1.12.28`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11228)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.27...1.12.28)

=======

-   api-change:`athena`: [``botocore``] Update athena client to latest version
-   api-change:`rds-data`: [``botocore``] Update rds-data client to latest version
-   api-change:`eks`: [``botocore``] Update eks client to latest version
-   api-change:`organizations`: [``botocore``] Update organizations client to latest version

### [`v1.12.27`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11227)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.26...1.12.27)

=======

-   api-change:`apigatewayv2`: [``botocore``] Update apigatewayv2 client to latest version
-   api-change:`eks`: [``botocore``] Update eks client to latest version
-   api-change:`route53`: [``botocore``] Update route53 client to latest version

### [`v1.12.26`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11226)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.25...1.12.26)

=======

-   api-change:`servicecatalog`: [``botocore``] Update servicecatalog client to latest version

### [`v1.12.25`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11225)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.24...1.12.25)

=======

-   api-change:`outposts`: [``botocore``] Update outposts client to latest version
-   api-change:`acm`: [``botocore``] Update acm client to latest version

### [`v1.12.24`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11224)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.23...1.12.24)

=======

-   api-change:`rds`: [``botocore``] Update rds client to latest version
-   api-change:`mediaconnect`: [``botocore``] Update mediaconnect client to latest version
-   api-change:`personalize`: [``botocore``] Update personalize client to latest version

### [`v1.12.23`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11223)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.22...1.12.23)

=======

-   api-change:`mediaconvert`: [``botocore``] Update mediaconvert client to latest version

### [`v1.12.22`](https://togithub.com/boto/boto3/blob/master/CHANGELOG.rst#&#8203;11222)

[Compare Source](https://togithub.com/boto/boto3/compare/1.12.21...1.12.22)

=======

-   api-change:`s3control`: [``botocore``] Update s3control client to latest version
-   bugfix:Stubber: [``botocore``] fixes `#&#8203;1884 <https://github.com/boto/botocore/issues/1884>`\_\_
-   api-change:`cognito-idp`: [``botocore``] Update cognito-idp client to latest version
-   api-change:`ssm`: [``botocore``] Update ssm client to latest version
-   api-change:`ecs`: [``botocore``] Update ecs client to latest version
-   api-change:`elasticache`: [``botocore``] Update elasticache client to latest version

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Never, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [x] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#GoogleCloudPlatform/python-docs-samples).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. s3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants