Skip to content

Accessing DebugInformation with large payloads throws OutOfMemoryException when debug mode is enabled #8631

@nijelic

Description

@nijelic

Elastic.Clients.Elasticsearch version: 8.15.6

Elasticsearch version: 8.16

.NET runtime version: 8

Operating system version: linux

Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.

When calling response.DebugInformation after configuring ConnectionSettings with .DisableDirectStreaming() and .EnableDebugMode(), the application throws a System.OutOfMemoryException.

It appears that the StringBuilder.ToString() call inside ElasticsearchResponse.get_DebugInformation() allocates excessive memory, possibly due to large request/response payloads or logs. This results in a crash instead of returning debug information as expected.

Steps to reproduce:

  1. Configure the client using:
    (ElasticsearchClientSettings settings)
    settings
    .DisableDirectStreaming()
    .EnableDebugMode()
    .PrettyJson();
  2. Execute a request expected to generate a large debug log (e.g., bulk insert or large query).
  3. Access response.DebugInformation

Expected behavior
A clear and concise description of what you expected to happen.

Accessing response.DebugInformation should return helpful debug output or at minimum handle large payloads gracefully without throwing OutOfMemoryException. Ideally, large content should be truncated, streamed, or otherwise managed to prevent memory exhaustion.

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):
Unavailable due to OutOfMemoryException being thrown when accessing response.DebugInformation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions