Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

boto3 GetObject and HeadObject Failure with python_wrapper #409

Closed
SiviP-Glossai opened this issue Jun 1, 2022 · 2 comments · Fixed by #412
Closed

boto3 GetObject and HeadObject Failure with python_wrapper #409

SiviP-Glossai opened this issue Jun 1, 2022 · 2 comments · Fixed by #412
Assignees

Comments

@SiviP-Glossai
Copy link

I am running a simple python server, with no framework, calling @epsagon.python_wrapper over the main function.
I use boto3 to make Put/Get/Head operations on an S3 bucket. Only Put operation registeres in the traces

I ran with debug and got the following error for each Head/Get:

[EPSAGON_DEBUG] Epsagon exception: Invalid format string
Traceback (most recent call last):
  File "C:\Git\Production2\glvideo\.venv\lib\site-packages\epsagon\modules\general_wrapper.py", line 35, in wrapper
    factory.create_event(
  File "C:\Git\Production2\glvideo\.venv\lib\site-packages\epsagon\events\botocore.py", line 2061, in create_event
    event = event_class(
  File "C:\Git\Production2\glvideo\.venv\lib\site-packages\epsagon\events\botocore.py", line 213, in __init__
    super(BotocoreS3Event, self).__init__(
  File "C:\Git\Production2\glvideo\.venv\lib\site-packages\epsagon\events\botocore.py", line 77, in __init__
    self.update_response(response)
  File "C:\Git\Production2\glvideo\.venv\lib\site-packages\epsagon\events\botocore.py", line 254, in update_response
    response['LastModified'].strftime('%s')
ValueError: Invalid format string
-----

The bug seems to be you are using:
response['LastModified'].strftime('%s')
Instead of:
response['LastModified'].strftime('%S')

@SiviP-Glossai SiviP-Glossai changed the title GetObject anf HeadObject with python_wrapper boto3 GetObject and HeadObject Failure with python_wrapper Jun 1, 2022
@sagivr2020 sagivr2020 self-assigned this Jun 6, 2022
@sagivr2020
Copy link
Member

Hi @SiviP-Glossai, as discussed on Intercom, the issue didn't reproduce on our side.
The versions used to reproduce are:
Python - 3.8.0
Epsagon - 1.79.0
Boto3 - 1.24.2

Please check if it happens when Epsagon is disabled (by using the environment variable DISABLE_EPSAGON and setting it to True, then re-run it).
In case it won't happen, please share a code snippet.
Thanks.

@SiviP-Glossai
Copy link
Author

@sagivr2020

This is system dependant. See: https://stackoverflow.com/questions/11743019/convert-python-datetime-to-epoch-with-strftime
They say it is not recommended to use %s as it is not documented and will not work for all systems.
I am using Linux Alpine Docker in my case.

@sagivr2020 sagivr2020 linked a pull request Jun 7, 2022 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants