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

'NoneType' object has no attribute 'strftime' #62

Open
ahmadalli opened this issue Jun 2, 2020 · 4 comments
Open

'NoneType' object has no attribute 'strftime' #62

ahmadalli opened this issue Jun 2, 2020 · 4 comments

Comments

@ahmadalli
Copy link

I'm trying store afile into sqlalchemy table. I'm using s3 boto interface with minio. The file gets uploaded but I get this exception:

'NoneType' object has no attribute 'strftime'

this is the stacktrace from minio:

  File "sqlalchemy/orm/attributes.py", line 272, in __set__
    self.impl.set(
  File "sqlalchemy/orm/attributes.py", line 865, in set
    value = self.fire_replace_event(
  File "sqlalchemy/orm/attributes.py", line 873, in fire_replace_event
    value = fn(
  File "sqlalchemy/orm/events.py", line 2165, in wrap
    return fn(target, *arg)
  File "depot/fields/sqlalchemy.py", line 75, in _field_set
    value = upload_type(value, column_type._upload_storage)
  File "depot/fields/interfaces.py", line 52, in __init__
    self.process_content(content)
  File "depot/fields/upload.py", line 44, in process_content
    self['uploaded_at'] = saved_file.last_modified.strftime('%Y-%m-%d %H:%M:%S')
@amol-
Copy link
Owner

amol- commented Jun 2, 2020

Given that the last_modifed is provided through a custom x-depot-modified metadata ( https://github.com/amol-/depot/blob/master/depot/io/boto3.py#L174 ) could it be that minio is not properly saving that attribute? At that point, is the x-depot-filename' metadata correctly saved instead?

Both of them are used extensively by DEPOT when serving files (to serve them with correct filename and to handle caching correctly) so it's not feasible to just ignore those if they are not available.

@ahmadalli
Copy link
Author

this is part of the debug log:

[2020-06-03 09:57:09]: 568 DEBUG http://127.0.0.1:9000 "HEAD /<bucket>/b8f4930a-a55a-11ea-b61a-00155d5f7e2f HTTP/1.1" 200 0
[2020-06-03 09:57:09]: 568 DEBUG Response headers: {'Accept-Ranges': 'bytes', 'Content-Disposition': 'inline;filename="724e64a8-1fce-4a2f-8d9e-da3fc95421ef.model";filename*=utf-8\'\'724e64a8-1fce-4a2f-8d9e-da3fc95421ef.model', 'Content-Length': '3624043624', 'Content-Security-Policy': 'block-all-mixed-content', 'Content-Type': 'application/octet-stream', 'ETag': '"75019ca6aad98b76b8a99e30f486493b"', 'Last-Modified': 'Wed, 03 Jun 2020 05:27:09 GMT', 'Server': 'MinIO/RELEASE.2020-05-16T01-33-21Z', 'Vary': 'Origin', 'X-Amz-Meta-X-Depot-Filename': '724e64a8-1fce-4a2f-8d9e-da3fc95421ef.model', 'X-Amz-Meta-X-Depot-Modified': '2020-06-03 05:26:05', 'X-Amz-Request-Id': '1614F16F74FE66CC', 'X-Xss-Protection': '1; mode=block', 'Date': 'Wed, 03 Jun 2020 05:27:09 GMT'}
[2020-06-03 09:57:09]: 568 DEBUG Response body:
b''

there's a header named X-Amz-Meta-X-Depot-Modified so I think the metadata has been set properly

@amol-
Copy link
Owner

amol- commented Jun 3, 2020

Thanks, looks like the issue might be that it got prefixed with X-Amz-Meta-.
Is the prefixing happening server side or you used any replacement of boto for the upload?

I wonder if the problem is that due to the prefixing DEPOT is unable to fetch back the metadata ( https://github.com/amol-/depot/blob/master/depot/io/boto3.py#L39 )

@ahmadalli
Copy link
Author

apparently X-Amz-Meta- is the standard for user defined metadata on s3 api specification +. but I think it should be handled on the boto part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants