Skip to content

[cli] content init does not show HTTP error response body #153

@bahdan111

Description

@bahdan111

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?

  1. Configure a channel in channels.yaml with a field that fails server-side validation
  2. Run statgpt content init (or poetry run python -m statgpt.cli, then content init)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions