From 43692e6b16c9b94124c8f15f4be07df39a99ae6c Mon Sep 17 00:00:00 2001 From: jay23606 <4602056+jay23606@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:23:43 -0400 Subject: [PATCH] fix: report the status for an error response with an empty body The CLI printed a traceback for an empty 502 or 405 response. Every non-2xx response now carries its statusCode, and a non-object body gets the standard reason phrase as error. An API body with its own statusCode still wins. Co-Authored-By: Claude Haiku 5.5 --- cli/odc-cli | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/odc-cli b/cli/odc-cli index 30365eb1e..d7fe9758f 100755 --- a/cli/odc-cli +++ b/cli/odc-cli @@ -21,6 +21,7 @@ from argparse import ( RawTextHelpFormatter, ) from datetime import datetime, timezone +from http import HTTPStatus from typing import Any, Callable from urllib.error import HTTPError, URLError from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse, quote @@ -214,7 +215,15 @@ class HttpResponse: props['data'] = self.data props['statusCode'] = self.status or 'N/A' elif not self.ok: - props.update(**self.data) + # Every failure carries its status; an API body with its own statusCode still wins. + props['statusCode'] = self.status or 'N/A' + if isinstance(self.data, dict): + props.update(self.data) + else: + try: + props['error'] = HTTPStatus(self.status).phrase + except (TypeError, ValueError): + pass return to_json(props) @property