ARCHIVED TRAINING / piskvorky/smart_open
piskvorky__smart_open-889
This is a preserved training example. Membership in the current training wave has not been verified.
Problem statement
Reading a 0 B file from s3 raises KeyError
#### Problem description
A problem is somewhat similar to the one described here https://github.com/RaRe-Technologies/smart_open/issues/548 , though the Error is not the same.
Be sure your description clearly answers the following questions:
- What are you trying to achieve?
I'm trying to read the file that might be empty in S3.
- What is the expected result?
The file is read without exceptions.
- What are you seeing instead?
KeyError exception is thrown
#### Steps/code to reproduce the problem
- Have an empty file in S3
- Run the following code
```python
from smart_open import open
with open('S3_uri', 'rb') as file:
file.read()
```
Traceback:
```python
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 330, in _get
return client.get_object(Bucket=bucket, Key=key, Range=range_string)
File "/home/user/.local/lib/python3.8/site-packages/botocore/client.py", line 386, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/user/.local/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 438, in _open_body
response = _get(
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 338, in _get
raise wrapped_error from error
OSError: unable to access bucket: 'mybucket' key: 'existing_file' version: None error: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.8/site-packages/smart_open/smart_open_lib.py", line 235, in open
binary = _open_binary_stream(uri, binary_mode, transport_params)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/smart_open_lib.py", line 398, in _open_binary_stream
fobj = submodule.open_uri(uri, mode, transport_params)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 224, in open_uri
return open(parsed_uri['bucket_id'], parsed_uri['key_id'], mode, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 291, in open
fileobj = Reader(
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 574, in __init__
self.seek(0)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 666, in seek
self._current_pos = self._raw_reader.seek(offset, whence)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 417, in seek
self._open_body(start, stop)
File "/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py", line 450, in _open_body
self._position = self._content_length = int(error_response['ActualObjectSize'])
KeyError: 'ActualObjectSize'
```
#### Versions
Please provide the output of:
```python
smart_open 5.2.1
```
#### Checklist
Before you create the issue, please make sure you have:
- [X] Described the problem clearly
- [X] Provided a minimal reproducible example, including any required data
- [X] Provided the version numbers of the relevant software
Training membership
opd_e4b_pure_v6b
Task issues extracted from preserved verified_rft_messages training examples. This is not a verified current RL wave manifest.
Task and snapshot provenance
Snapshot captured 2026-11-12T17:06:59.476467+00:00 · Autoresearch-Arena/gemma-4-developer-agent
{
"datasets": [
"opd_e4b_pure_v6b"
],
"examples": 3,
"instance_id": "piskvorky__smart_open-889",
"problem_statement": "Reading a 0 B file from s3 raises KeyError\n#### Problem description\r\nA problem is somewhat similar to the one described here https://github.com/RaRe-Technologies/smart_open/issues/548 , though the Error is not the same. \r\n\r\nBe sure your description clearly answers the following questions:\r\n\r\n- What are you trying to achieve?\r\nI'm trying to read the file that might be empty in S3.\r\n- What is the expected result?\r\nThe file is read without exceptions.\r\n- What are you seeing instead?\r\nKeyError exception is thrown\r\n\r\n#### Steps/code to reproduce the problem\r\n- Have an empty file in S3\r\n- Run the following code\r\n```python\r\nfrom smart_open import open\r\nwith open('S3_uri', 'rb') as file:\r\n file.read()\r\n```\r\nTraceback:\r\n```python\r\nTraceback (most recent call last):\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 330, in _get\r\n return client.get_object(Bucket=bucket, Key=key, Range=range_string)\r\n File \"/home/user/.local/lib/python3.8/site-packages/botocore/client.py\", line 386, in _api_call\r\n return self._make_api_call(operation_name, kwargs)\r\n File \"/home/user/.local/lib/python3.8/site-packages/botocore/client.py\", line 705, in _make_api_call\r\n raise error_class(parsed_response, operation_name)\r\nbotocore.exceptions.ClientError: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 438, in _open_body\r\n response = _get(\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 338, in _get\r\n raise wrapped_error from error\r\nOSError: unable to access bucket: 'mybucket' key: 'existing_file' version: None error: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/smart_open_lib.py\", line 235, in open\r\n binary = _open_binary_stream(uri, binary_mode, transport_params)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/smart_open_lib.py\", line 398, in _open_binary_stream\r\n fobj = submodule.open_uri(uri, mode, transport_params)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 224, in open_uri\r\n return open(parsed_uri['bucket_id'], parsed_uri['key_id'], mode, **kwargs)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 291, in open\r\n fileobj = Reader(\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 574, in __init__\r\n self.seek(0)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 666, in seek\r\n self._current_pos = self._raw_reader.seek(offset, whence)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 417, in seek\r\n self._open_body(start, stop)\r\n File \"/home/user/.local/lib/python3.8/site-packages/smart_open/s3.py\", line 450, in _open_body\r\n self._position = self._content_length = int(error_response['ActualObjectSize'])\r\nKeyError: 'ActualObjectSize'\r\n```\r\n\r\n#### Versions\r\n\r\nPlease provide the output of:\r\n\r\n```python\r\nsmart_open 5.2.1\r\n```\r\n\r\n#### Checklist\r\n\r\nBefore you create the issue, please make sure you have:\r\n\r\n- [X] Described the problem clearly\r\n- [X] Provided a minimal reproducible example, including any required data\r\n- [X] Provided the version numbers of the relevant software",
"repo": "piskvorky/smart_open",
"source": "v2/experiments/train_data/opd_e4b_pure_v6b/verified_rft_messages.jsonl",
"source_sha256": "0f62460a9706eea5e1605255896f191ab00cb5706c5f1f2e1c293e9a718218dc"
}{
"captured_at": "2026-11-12T17:06:59.476467+00:00",
"membership": "archived training",
"membership_evidence": "Task issues extracted from preserved verified_rft_messages training examples. This is not a verified current RL wave manifest.",
"name": "Preserved post-training task archive",
"source": "Autoresearch-Arena/gemma-4-developer-agent",
"source_revision": "016496de222aaafca0d4ee4c18efc63ba616f76e",
"sources": [
{
"path": "v2/experiments/train_data/opd_e4b_cispo_v5/verified_rft_messages.jsonl",
"sha256": "a43610ad0dfb6ace95375cfae09000f41afc0338cc925af870a4ade7a9b20c4c"
},
{
"path": "v2/experiments/train_data/opd_e4b_hybrid_v3/verified_rft_messages.jsonl",
"sha256": "bd326303eb127e8e5e08f03daf97bb88d79d19709d59f3f93f348bc56686a8df"
},
{
"path": "v2/experiments/train_data/opd_e4b_onpolicy_v3/verified_rft_messages.jsonl",
"sha256": "960c680e797e823a0d3a22f4b1d5ef60a72971373d703b877340b0c9126aaf68"
},
{
"path": "v2/experiments/train_data/opd_e4b_pure_v6a/verified_rft_messages.jsonl",
"sha256": "f045b7ca5b3883a1e2eaee81e1c02a4a1b53dd7b7b36e98bacb2ba5823a15148"
},
{
"path": "v2/experiments/train_data/opd_e4b_pure_v6b/verified_rft_messages.jsonl",
"sha256": "0f62460a9706eea5e1605255896f191ab00cb5706c5f1f2e1c293e9a718218dc"
},
{
"path": "v2/experiments/train_data/opd_e4b_pure_v7/verified_rft_messages.jsonl",
"sha256": "e37f7bd675322f3f81500b73559d60d5f602ca0537bf19f5cb06332c728c7b72"
},
{
"path": "v2/experiments/train_data/opd_e4b_pure_v7b/verified_rft_messages.jsonl",
"sha256": "b864bdc8695183433eef6e31cb8d33fad44ba3aded2170c1ade4ad5b2944ce23"
},
{
"path": "v2/experiments/train_data/opd_e4b_self_audit_v4/verified_rft_messages.jsonl",
"sha256": "0026023745afb8f3dc1c176dc7f7171157b4ad5a66656b524af218e8e19ceee6"
},
{
"path": "v2/experiments/train_data/rft_e4b_aligned_v2/verified_rft_messages.jsonl",
"sha256": "92a4515fee9d152b0d4c510ee3ce4caaaffe2003ba7584469f8027f174aab18c"
},
{
"path": "v2/experiments/train_data/rft_v1/verified_rft_messages.jsonl",
"sha256": "a42453ccd7ac7680b0a03865e8e7080bc8bf74c8d9d193b440c441ed46f8512b"
},
{
"path": "v2/experiments/train_data/rft_v2/verified_rft_messages.jsonl",
"sha256": "18f4b3bd7e651f83c6acab479c9475e3fa50dc652a384f309e97146983ac85ba"
}
]
}