LineIterator hangs forever if the streamed response ends without a trailing newline
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in sagemaker-core/src/sagemaker/core/iterators.py at LineIterator.next, then run the provided reproduction with a final streamed chunk that lacks a trailing newline. Confirm that iteration yields both response lines and terminates instead of retrying the exhausted byte iterator forever; add coverage for this unterminated final chunk if the surrounding tests provide a suitable location.
Written by the indexing model from the issue text.
Description
LineIterator.__next__ hangs forever if the last chunk of a streamed response has no trailing newline.
sagemaker-core/src/sagemaker/core/iterators.py:
except StopIteration:
if self.read_pos < self.buffer.getbuffer().nbytes:
continue
raise
continue re-reads the same unterminated line, fails the same check, calls next() on the now-exhausted byte_iterator again, gets StopIteration again, forever. Nothing in that branch changes read_pos or the buffer.
Repro:
from sagemaker.core.iterators import LineIterator
chunks = [
{"PayloadPart": {"Bytes": b'{"outputs": [" a"]}\n'}},
{"PayloadPart": {"Bytes": b'{"outputs": [" b"]}'}},
]
for line in LineIterator(iter(chunks)):
print(line)
Prints the first line then hangs.
Will open a PR.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 1.3k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 42
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/sagemaker-python-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/sagemaker-python-sdk#6253 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 93/100
aws/sagemaker-python-sdk#6232 ·
-
component: model monitor type: bug
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
aws/sagemaker-python-sdk#6206 ·
-
component: model builder type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
aws/sagemaker-python-sdk#6199 ·
-
component: jumpstart type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws/sagemaker-python-sdk#6191 ·
All issues in aws/sagemaker-python-sdk
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·