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

S3 Decorator Error: AttributeError: 'NoneType' object has no attribute 'logger' Traceback #15

Open
smt7174 opened this issue Jun 11, 2020 · 1 comment
Labels
answered Answered and waiting for the requester

Comments

@smt7174
Copy link

smt7174 commented Jun 11, 2020

I got an error when trying to use s3 decorator.

My code is below. (This is nearly equal to sample code in
https://github.com/serverless-operations/jeffy)

# Using python-requirements plugin of Serverless Framework.
# Unzipping package because 'pythonRequirements.zip' parameter is set true in 
# Serverless Framework
# Probably, unzipping operation effects nothing. 
# (In case of rest_api decorator, no error raised.) 
try:
    import unzip_requirements
except ImportError:
    pass

from jeffy.framework import get_app
app = get_app()

@app.handlers.s3()
def handler(event, context):

    print(event['bucket_name'])
    print(event['key'])

# Instead of using print method, I tried to use app.logger.info method, but the same error raised. 
# app.logger.info({'bucket': event['bucket_name']})

And error is the below.

[ERROR] AttributeError: 'NoneType' object has no attribute 'logger' Traceback (most recent call last):   
  File "/tmp/sls-py-req/jeffy/handlers/s3.py", line 50, in wrapper self.app.logger.exception(e)

Additional information:
In case of executing the code below, no error raised.

try:
    import unzip_requirements
except ImportError:
    pass

import json
from jeffy.framework import get_app
app = get_app()

def handler(event, context):

    app.logger.info({'bucket': event['Records'][0]['s3']['bucket']['name']})
@marcy-terui
Copy link

marcy-terui commented Jun 17, 2020

Thank you for your reporting 👍

S3 handler requires s3:GetObject permission. Maybe, your function does not allow s3:GetObject.
But in that case you should get another error message. We will continue to examine why it is.

And we haven't enough information about the required permissions. So we will fix it soon.

@marcy-terui marcy-terui added the answered Answered and waiting for the requester label Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Answered and waiting for the requester
Projects
None yet
Development

No branches or pull requests

2 participants