mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-26 19:44:51 +02:00
[eric] browser: log write-tier failures (adapter bug=WARNING, site-reject=INFO) so a systemically-broken fast path isn't silently invisible to ops
This commit is contained in:
@@ -19,6 +19,7 @@ SAFETY (this IS the posture flip away from GET/HEAD-only, so the walls are belt-
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
@@ -32,6 +33,8 @@ from typeguard import typechecked
|
||||
|
||||
from backend.apps.social_shims.session_source import get_session
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
WRITE_METHODS = frozenset({"POST", "PUT", "PATCH", "DELETE"})
|
||||
# CSRF header a site derives from a cookie (so it survives a fresh borrowed session). Small on
|
||||
# purpose: most cookie-auth internal APIs need nothing extra; this covers the common header case.
|
||||
@@ -206,5 +209,10 @@ def replay_write(method: str, url: str, body: Dict[str, Any], origin: str,
|
||||
try:
|
||||
status, text = issue_request(method, url, body, headers)
|
||||
except Exception as e:
|
||||
# UNEXPECTED: the request itself blew up (network/DNS/TLS), not a same-origin/captured refusal. Fails open to the UI, so log it or the broken route-write tier is invisible.
|
||||
logger.warning(f"[route-write] {method} {url} request FAILED (fast path broken here): {e}")
|
||||
return ReplayOutcome(ok=False, error=str(e)[:160], latency_ms=int((time.monotonic() - t0) * 1000))
|
||||
return outcome_from_response(status, text, int((time.monotonic() - t0) * 1000))
|
||||
out = outcome_from_response(status, text, int((time.monotonic() - t0) * 1000))
|
||||
if not out.ok:
|
||||
logger.info(f"[route-write] {method} {url} rejected by site: HTTP {out.status}")
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user