KeyError: 'x-amz-version-id'
cheehook opened this issue · 4 comments
Hi, I am having issues while trying to connect to my sqlite3.db in S3 bucket.
My script is a s follow:
import os, sys
import json
from functools import partial
from sqlite_s3_query import sqlite_s3_query
credentials = json.load (open(sys.argv[1], "r"))
os.environ['AWS_REGION'] = credentials['region']
os.environ['AWS_ACCESS_KEY_ID'] = credentials['access-key-id']
os.environ['AWS_SECRET_ACCESS_KEY'] = credentials['secret-access-key']
def get_credentials(_):
return (
os.environ['AWS_REGION'],
os.environ['AWS_ACCESS_KEY_ID'],
os.environ['AWS_SECRET_ACCESS_KEY'],
os.environ.get('AWS_SESSION_TOKEN') # Only needed for temporary credentials
)
query_my_db = partial(sqlite_s3_query,
url = credentials['s3-object-url'],
get_credentials=get_credentials,
)
with \
query_my_db() as query, \
query('SELECT * FROM MODEL') as (columns, rows):
for row in rows:
print(row)
This is the error log:
Traceback (most recent call last):
File "read_s3.py", line 27, in <module>
query_my_db() as query, \
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlite_s3_query.py", line 313, in sqlite_s3_query
get_vfs(http_client) as vfs, \
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlite_s3_query.py", line 144, in get_vfs
version_id = head_headers['x-amz-version-id']
File "/home/ubuntu/.local/lib/python3.6/site-packages/httpx/_models.py", line 991, in __getitem__
raise KeyError(key)
KeyError: 'x-amz-version-id'
To verify that the IAM credentials are correct, I load the same json file and download the sqlitedb file using boto3 and it was successful.
Do you have any idea on what seems to be the problem? ( I am not using temporary credentials, thus os.environ.get('AWS_SESSION_TOKEN')
is None
)
Thank you.
Ah it sounds like versioning isn’t enabled on the bucket - the error you get is consistent with that.
(I think a clearer error message would be good in this case, but at the moment I’m not pro adding support for non-versioned buckets)
Let me know if not having versioning enabled was indeed this issue?
(Otherwise will close the issue)
Hi, yes. The S3 bucket which I was using does not have versioning.