From 1625b71271f6f0b5d7fb40f2219e3ec5a8744d31 Mon Sep 17 00:00:00 2001 From: jehrr <79864894+jehrr@users.noreply.github.com> Date: Fri, 16 Oct 2026 07:53:50 +0000 Subject: [PATCH] Show the Browser API's error body instead of a bare HTTP status Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CKsd7q25N19WzUZjrAdzx8 --- CHANGELOG.md | 5 +++++ tools/browser_profile_client.py | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad50647..ca00f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ entry in a blockquote. ### Fixed +* **`tools/browser_profile_client.py` hid the Browser API's error code.** An + HTTP error from the API was reported as the bare status ("404 Client Error: + Not Found"), dropping the body that names the cause, e.g. + `ERROR_ACCOUNT_NOT_FOUND` for a profile id passed as `--account-id`. The + body is now printed with credentials masked. * **Session minting on a gateway URL with no login.** `connection --mint-session` spliced the new login in front of `http://` when `AVITO_PROXY` had an empty username, so the rebuilt URL had no host and the diff --git a/tools/browser_profile_client.py b/tools/browser_profile_client.py index 7290b25..870b19f 100644 --- a/tools/browser_profile_client.py +++ b/tools/browser_profile_client.py @@ -161,11 +161,19 @@ def _call(method: str, path: str, key: str, *, params=None, body=None): url = f"{BASE}{path}" try: r = requests.request(method, url, params=params, json=body, timeout=TIMEOUT) - r.raise_for_status() except requests.RequestException as e: # The key rides in the query string on GET, and `requests` puts the # whole URL into this message. Redact before it reaches a log. sys.exit(f"!! {method} {path} failed: {redact(e, key)}") + if not r.ok: + # The API names the cause in the body (ERROR_ACCOUNT_NOT_FOUND, + # ERROR_CUSTOM_PROXY_AUTH, ...); a bare "404 Not Found" hid it. + try: + detail = json.dumps(safe(r.json())) + except ValueError: + detail = "(non-JSON body, %d bytes)" % len(r.content) + sys.exit(f"!! {method} {path} failed: HTTP {r.status_code}: " + f"{redact(detail, key)}") try: data = r.json() except ValueError: