Skip to content

[BUG] Response body is missing from custom exception message #22351

Closed

Description

@ddl-rliu

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When using the API client and encountering an exception, the user sees

E           ...exceptions.ServiceException: (500)
E           Reason: Internal Server Error
E           HTTP response headers: HTTPHeaderDict(...)
E           HTTP response body: error=None

This is unfortunate, as the useful response body of the exception is "overriden" by the not-useful response data "error=None"

openapi-generator version

7.14.0

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

Create a call against a client which produces e.g. a 500 error, with an http response containing response data, and a useful response body. The useful response body will be missing from the exception str.

Related issues/PRs

#22352

Suggest a fix

master...ddl-rliu:openapi-generator:patch-1

Activity

  1. ddl-rliu commented on Nov 14, 2025

    @ddl-rliu
    ContributorAuthor

    I found it a bit hard to describe the issue in words, but looking at the code the issue (and fix!) is relatively straightforward.

    modules/openapi-generator/src/main/resources/python/exceptions.mustache
    ...
            if self.data or self.body:
                error_message += "HTTP response body: {0}\n".format(self.data or self.body)
    

    Note that the response body may get "overriden" by the response data, which is unfortunate in cases where the repsonse body contains very useful logs.

  2. added a commit that references this issue on Nov 16, 2025
    547eee1
  3. added a commit that references this issue on Dec 25, 2025
    8ceb342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions