-
Notifications
You must be signed in to change notification settings - Fork 1
Description
StatGPT Backend version: latest
Short description:
When content init receives an HTTP error (e.g. 422 Unprocessable Entity), the CLI only shows the status code and URL but not the response body containing the actual validation error details.
What steps will reproduce the bug?
- Configure a channel in
channels.yamlwith a field that fails server-side validation - Run
statgpt content init(orpoetry run python -m statgpt.cli, thencontent init) - Observe the error output:
✗ Failed to process client imf: Client error '422 Unprocessable Entity' for url 'https://.../admin/api/v1/channels/1' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
What is the expected behavior?
The error message should include the response body from the server, which contains the Pydantic validation error details (field names, error messages, etc.). For example:
✗ Failed to process client imf: HTTP 422 for POST https://.../admin/api/v1/channels/1:
{"detail":[{"loc":["body","details","llm_model"],"msg":"field required","type":"value_error.missing"}]}
This would allow users to immediately identify which field(s) failed validation without needing to manually replay the request with curl.
What do you see instead?
Only the HTTP status code and a generic MDN documentation link. The response body with validation details is discarded by httpx's raise_for_status().
Root cause
In statgpt/cli/shared/admin_client.py, all API methods call resp.raise_for_status() directly. When httpx raises HTTPStatusError, its string representation only includes the status line and URL — not the response body. The response body (accessible via resp.text) is never logged or included in the error.