degrade optional workspace writes safely

This commit is contained in:
2026-07-19 13:35:04 -03:00
parent 02a9da79db
commit 2e7685aaa2
2 changed files with 24 additions and 1 deletions

View File

@@ -409,7 +409,11 @@ def _read_uploaded_workspace_file(ctx: RunContext[PlatformUserAuth], path: str)
async def _write_workspace_output(ctx: RunContext[PlatformUserAuth], path: str, payload: dict[str, Any], warnings: list[str]) -> None:
data = json.dumps(payload, indent=2, sort_keys=True).encode("utf-8")
workspace = ctx.workspace
try:
workspace = ctx.workspace
except PermissionError as exc:
warnings.append(f"workspace write skipped: {str(exc)[:160]}")
return
writer = getattr(workspace, "write_bytes", None)
if callable(writer):
writer(path, data)