fix(backend/copilot): address review comments cycle 1

- Replace redundant elif guard with plain else in service.py restore path
- Use isinstance(…, Exception) instead of BaseException in gather error
  checks for upload_cli_session (BaseException swallows KeyboardInterrupt)
- Use explicit list side_effect in test_returns_none_when_file_not_found
  to document the two-call contract of the concurrent retrieve gather
This commit is contained in:
Zamil Majdy
2026-04-16 01:47:28 +07:00
parent af8a86e6b6
commit 2ec20e76bd
3 changed files with 7 additions and 6 deletions

View File

@@ -2503,9 +2503,7 @@ async def stream_chat_completion_sdk(
log_prefix,
)
transcript_covers_prefix = False
elif (
config.claude_agent_use_resume and user_id and len(session.messages) > 1
):
else:
# No CLI session in GCS — reconstruct from DB messages as last-resort fallback.
prior = session.messages[:-1]
reconstructed = _session_messages_to_transcript(prior)

View File

@@ -762,12 +762,12 @@ async def upload_cli_session(
),
return_exceptions=True,
)
if isinstance(session_result, BaseException):
if isinstance(session_result, Exception):
logger.warning(
"%s Failed to upload CLI session file: %s", log_prefix, session_result
)
return
if isinstance(meta_result, BaseException):
if isinstance(meta_result, Exception):
logger.warning(
"%s Failed to upload CLI session meta: %s", log_prefix, meta_result
)

View File

@@ -982,7 +982,10 @@ class TestRestoreCliSession:
from .transcript import restore_cli_session
mock_storage = AsyncMock()
mock_storage.retrieve.side_effect = FileNotFoundError("not found")
mock_storage.retrieve.side_effect = [
FileNotFoundError("no session"),
FileNotFoundError("no meta"),
]
with patch(
"backend.copilot.transcript.get_workspace_storage",