<EDIT> Closing this, as uninstalling and reinstalling moto from scratch fixed the issue. </EDIT>
I am using boto3==1.28.45 with moto==1.3.14 running locally on port 5353.
This has worked for years, but for my machine alone, uploading to subdirs of an existing bucket is now failing with 404.
I can't figure out where to even start debugging this, and would appreciate any ideas of what to think about.
<EDIT> I understand that it's not really a "subdir", it's a key-value store, but it seems anything with slashes is failing </EDIT>
(py-3.8.13) % cat test.txt
test
(py-3.8.13) % python
Python 3.8.13 (default, Aug 26 2022, 14:51:46)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> client = boto3.client('s3', region_name='us-east-1', endpoint_url='http://127.0.0.1:5353')
>>> client.create_bucket(Bucket='test')
{'ResponseMetadata': {'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Werkzeug/2.3.5 Python/3.8.13', 'date': 'Tue, 12 Sep 2023 19:17:47 GMT', 'content-type': 'text/html; charset=utf-8', 'content-length': '158', 'connection': 'close'}, 'RetryAttempts': 0}}
>>> client.upload_file('test.txt', 'test', 'test.txt')
>>> client.upload_file('test.txt', 'test', 'test_dir/test.txt')
Traceback (most recent call last):
... [ skipped for brevity ]
botocore.exceptions.ClientError: An error occurred (404) when calling the PutObject operation: Not Found
I've tried the following as well:
>>> resource = boto3.resource('s3', region_name='us-east-1', endpoint_url='http://127.0.0.1:5353')
>>> bucket = resource.Bucket('test')
>>> bucket.upload_file('test.txt', 'test.txt')
>>> bucket.upload_file('test.txt', 'test_dir/test.txt')
Traceback (most recent call last):
...
botocore.exceptions.ClientError: An error occurred (404) when calling the PutObject operation: Not Found
>>> bucket.put_object(Key='test_dir/')
>>> list(bucket.objects.iterator())
[s3.ObjectSummary(bucket_name='test', key='test.txt'), s3.ObjectSummary(bucket_name='test', key='test_dir/')]
>>> bucket.upload_file('test.txt', 'test_dir/test.txt')
Traceback (most recent call last):
...
botocore.exceptions.ClientError: An error occurred (404) when calling the PutObject operation: Not Found
Moto_server logs are as expected:
127.0.0.1 - - [12/Sep/2023 12:28:15] "PUT /test/test_dir/test.txt HTTP/1.1" 404 -
Uninstalling and reinstalling moto fixed the issue.