mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
fix(backend/copilot): sanitize OSError path in write log, patch config in mode-check tests
- _write_cli_session_to_disk: log basename + e.strerror instead of raw OSError to avoid exposing host directory paths in warning logs - TestRestoreCliSessionModeCheck: patch config.claude_agent_use_resume=True so tests are not silently skipped when CLAUDE_AGENT_USE_RESUME=false in env - baseline/transcript_integration_test.py: fix stale docstring (restore_cli_session → download_transcript)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
Exercises the real helpers in ``baseline/service.py`` that restore,
|
||||
validate, load, append to, backfill, and upload the CLI session.
|
||||
Storage is mocked via ``restore_cli_session`` / ``upload_cli_session``
|
||||
Storage is mocked via ``download_transcript`` / ``upload_transcript``
|
||||
patches; no network access is required.
|
||||
"""
|
||||
|
||||
|
||||
@@ -883,7 +883,12 @@ def _write_cli_session_to_disk(
|
||||
)
|
||||
return True
|
||||
except OSError as e:
|
||||
logger.warning("%s Failed to write CLI session file: %s", log_prefix, e)
|
||||
logger.warning(
|
||||
"%s Failed to write CLI session file %s: %s",
|
||||
log_prefix,
|
||||
os.path.basename(session_file),
|
||||
e.strerror or str(e),
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -660,10 +660,15 @@ class TestRestoreCliSessionModeCheck:
|
||||
mode="baseline",
|
||||
)
|
||||
|
||||
import backend.copilot.sdk.service as _svc_mod
|
||||
|
||||
download_mock = AsyncMock(return_value=baseline_restore)
|
||||
with patch(
|
||||
"backend.copilot.sdk.service.download_transcript",
|
||||
new=download_mock,
|
||||
with (
|
||||
patch(
|
||||
"backend.copilot.sdk.service.download_transcript",
|
||||
new=download_mock,
|
||||
),
|
||||
patch.object(_svc_mod.config, "claude_agent_use_resume", True),
|
||||
):
|
||||
result = await _restore_cli_session_for_turn(
|
||||
user_id="user-1",
|
||||
@@ -738,9 +743,14 @@ class TestRestoreCliSessionModeCheck:
|
||||
mode="sdk",
|
||||
)
|
||||
|
||||
with patch(
|
||||
"backend.copilot.sdk.service.download_transcript",
|
||||
new=AsyncMock(return_value=sdk_restore),
|
||||
import backend.copilot.sdk.service as _svc_mod
|
||||
|
||||
with (
|
||||
patch(
|
||||
"backend.copilot.sdk.service.download_transcript",
|
||||
new=AsyncMock(return_value=sdk_restore),
|
||||
),
|
||||
patch.object(_svc_mod.config, "claude_agent_use_resume", True),
|
||||
):
|
||||
result = await _restore_cli_session_for_turn(
|
||||
user_id="user-1",
|
||||
|
||||
Reference in New Issue
Block a user