Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion services/agent/e2e_u03_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ async def _cancel_old_run_fence(
current_code, current = _envelope(current_response)
if current_response.status_code != 200 or current_code != 0:
analysis_task.cancel()
raise ValueError("cancel_fence_state_unavailable")
raise ValueError(f"cancel_fence_state_unavailable:http={current_response.status_code}:code={current_code}")
if current.get("status") == "analyzing":
analysis_run_id = current.get("runId")
if not analysis_run_id:
Expand Down
23 changes: 23 additions & 0 deletions services/agent/tests/test_delivery_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@
u03 = importlib.util.module_from_spec(_SPEC)
_SPEC.loader.exec_module(u03)

@pytest.mark.parametrize("status,code", [(502, 50000), (200, 40900)])
def test_cancel_fence_preserves_safe_failed_read_diagnostics(status, code):
import asyncio
import httpx

async def scenario():
async def respond(request):
if request.method == "POST":
data = {"threadId": str(uuid.uuid4()), "draft": {}}
return httpx.Response(200, json={"code": 0, "message": "success", "data": data,
"traceId": "private-trace"})
return httpx.Response(status, json={"code": code, "message": "private-message",
"data": {"reason": "private-reason"},
"traceId": "private-trace"})

async with httpx.AsyncClient(transport=httpx.MockTransport(respond),
base_url="http://localhost") as session:
with pytest.raises(ValueError) as failure:
await u03._cancel_old_run_fence(session, str(uuid.uuid4()))
assert str(failure.value) == f"cancel_fence_state_unavailable:http={status}:code={code}"

asyncio.run(scenario())

def _prior_five_fixture(tmp_path, monkeypatch, *, unsupported_rejected=True, raw_records=None):
import agent_service.gate as gate

Expand Down
Loading