Skip to content

Validate MaxBodyCaptureSizeKb Configuration #113

@georgidhristov

Description

@georgidhristov

Description

DebugProbe currently allows MaxBodyCaptureSizeKb to be configured with negative values.

Negative values can break request and response body capture calculations, leading to unexpected behavior during body truncation and size validation.

Current Behavior

MaxBodyCaptureSizeKb can currently be configured with invalid values such as:

builder.Services.AddDebugProbe(options =>
{
    options.MaxBodyCaptureSizeKb = -1;
});

This may cause incorrect body size calculations and unexpected capture behavior.

Expected Behavior

DebugProbe should validate MaxBodyCaptureSizeKb and reject invalid values during application startup.

Suggested Fix

Validate MaxBodyCaptureSizeKb during options configuration or initialization.

Recommended validation:

MaxBodyCaptureSizeKb >= 0

A value of:

  • 0 disables body capture
  • Positive values enable body capture up to the configured limit

If an invalid value is provided, throw a clear configuration exception explaining the allowed range.

Result

After this change:

  • Invalid configuration is detected early.
  • Body capture calculations remain predictable.
  • Unexpected truncation or capture behavior is prevented.
  • Users receive clear feedback when configuration values are invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions