Skip to content

Commit 513df71

Browse files
meeseeksmachinebroden-wannerpre-commit-ci[bot]blink1073
authored
Backport PR #1233 on branch 1.x (Added error propagation to gateway_request function) (#1234)Co-authored-by: Broden Wanner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester <[email protected]>
* Backport PR #1233: Added error propagation to gateway_request function * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * lint --------- Co-authored-by: Broden Wanner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester <[email protected]>
1 parent a777102 commit 513df71

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file.
1010

1111
### Bugs fixed
1212

13-
- Backport PR #1212: Redact tokens, etc. in url parameters from request logs [#1214](https://github.com/jupyter-server/jupyter_server/pull/1214) ([@blink1073](https://github.com/blink1073))
13+
- Backport PR #1212: Redact tokens, etc. in url parameters from request logs [#1214](https://github.com/jupyter-server/jupyter_server/pull/1214) ([@blink1073](https://github.com/blink1073))
1414
- Backport PR #1193: Fix get_loader returning None when load_jupyter_server_extension is not found (#1193) (#1199)Co-authored-by: Steven Silvester <[email protected]> Co-authored-by: pre-commit-ci\[bot\] \<66853113+pre-commit-ci\[bot\]@users.noreply.github.com> [#1199](https://github.com/jupyter-server/jupyter_server/pull/1199) ([@cmd-ntrf](https://github.com/cmd-ntrf))
1515

1616
### Documentation improvements

jupyter_server/gateway/gateway_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,19 @@ async def gateway_request(endpoint: str, **kwargs: ty.Any) -> HTTPResponse:
506506
# NOTE: We do this here since this handler is called during the server's startup and subsequent refreshes
507507
# of the tree view.
508508
except HTTPClientError as e:
509+
error_reason = f"Exception while attempting to connect to Gateway server url '{GatewayClient.instance().url}'"
510+
error_message = str(e)
511+
if e.response:
512+
try:
513+
error_payload = json.loads(e.response.body)
514+
error_reason = error_payload.get("reason") or error_reason
515+
error_message = error_payload.get("message") or error_message
516+
except json.decoder.JSONDecodeError:
517+
error_reason = e.response.body.decode()
518+
509519
raise web.HTTPError(
510520
e.code,
511-
f"Error attempting to connect to Gateway server url '{GatewayClient.instance().url}'. "
521+
f"Error from Gateway: [{error_message}] {error_reason}. "
512522
"Ensure gateway url is valid and the Gateway instance is running.",
513523
) from e
514524
except ConnectionError as e:

0 commit comments

Comments
 (0)