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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tools/browser_profile_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading