Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address gemini bot comments
  • Loading branch information
Pulkit0110 committed Jan 2, 2026
commit 9a086e422d43ef74bb0fabd1783f2c96773e5cb8
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
self.user_buffer = user_buffer
self.persisted_size: int = 0
self.bytes_sent: int = 0
self.write_handle: Union[bytes, Any, None] = None
self.write_handle: Union[bytes, storage_type.BidiWriteHandle, None] = None
self.routing_token: Optional[str] = None
self.is_complete: bool = False

Expand All @@ -65,9 +65,6 @@ def generate_requests(
"""
Comment thread
Pulkit0110 marked this conversation as resolved.
write_state: _WriteState = state["write_state"]

# Mark that we have generated the first request for this stream attempt
state["first_request"] = False

if write_state.write_handle:
write_state.spec.write_handle = write_state.write_handle

Expand Down Expand Up @@ -141,6 +138,3 @@ async def recover_state_on_failure(
# Reset the user buffer to the last known good byte.
write_state.user_buffer.seek(write_state.persisted_size)
write_state.bytes_sent = write_state.persisted_size

# Mark next pass as a retry (not the absolute first request)
state["first_request"] = False
16 changes: 12 additions & 4 deletions tests/unit/asyncio/retry/test_reads_resumption_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
from google.cloud._storage_v2.types.storage import BidiReadObjectRedirectedError

_READ_ID = 1
LOGGER_NAME = "google.cloud.storage._experimental.asyncio.retry.reads_resumption_strategy"
LOGGER_NAME = (
"google.cloud.storage._experimental.asyncio.retry.reads_resumption_strategy"
)


class TestDownloadState(unittest.TestCase):
Expand Down Expand Up @@ -309,7 +311,9 @@ def test_update_state_missing_read_range_logs_warning(self):
with self.assertLogs(LOGGER_NAME, level="WARNING") as cm:
self.strategy.update_state_from_response(response, self.state)

self.assertTrue(any("missing read_range field" in output for output in cm.output))
self.assertTrue(
any("missing read_range field" in output for output in cm.output)
)

def test_update_state_unknown_id_logs_warning(self):
"""Verify we log a warning and continue when read_id is unknown."""
Expand All @@ -320,8 +324,12 @@ def test_update_state_unknown_id_logs_warning(self):
with self.assertLogs(LOGGER_NAME, level="WARNING") as cm:
self.strategy.update_state_from_response(response, self.state)

self.assertTrue(any(f"unknown or stale read_id {unknown_id}" in output for output in cm.output))

self.assertTrue(
any(
f"unknown or stale read_id {unknown_id}" in output
for output in cm.output
)
)

# --- Recovery Tests ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ def test_update_state_from_response(self):
def test_update_state_from_response_ignores_smaller_persisted_size(self):
strategy = self._make_one()
state = {
"write_state": _WriteState(None, 0, None),
"write_state": _WriteState(
mock.Mock(spec=storage_type.AppendObjectSpec),
0,
mock.Mock(spec=io.BytesIO),
),
}
write_state = state["write_state"]
write_state.persisted_size = 2048
Expand Down
1 change: 0 additions & 1 deletion tests/unit/asyncio/test_async_multi_range_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ async def test_download_ranges_via_async_gather(
)
]
),
None,
_storage_v2.BidiReadObjectResponse(
object_data_ranges=[
_storage_v2.ObjectRangeData(
Expand Down