Skip to content

fix: validate MaxBodyCaptureSizeKb rejects negative values#129

Merged
georgidhristov merged 1 commit into
DebugProbe:mainfrom
DevSars24:fix/validate-max-body-capture-size-kb
Jun 25, 2026
Merged

fix: validate MaxBodyCaptureSizeKb rejects negative values#129
georgidhristov merged 1 commit into
DebugProbe:mainfrom
DevSars24:fix/validate-max-body-capture-size-kb

Conversation

@DevSars24

@DevSars24 DevSars24 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #113

MaxBodyCaptureSizeKb could previously be set to negative values, which caused incorrect body size calculations and unexpected capture behavior during request/response truncation.

Root Cause

The property had no validation on the setter, allowing any integer value including negatives.

Changes

DebugProbe.AspNetCore/Options/DebugProbeOptions.cs

  • Replaced auto-property with a backing field + validated setter
  • Throws ArgumentOutOfRangeException with a clear message if value < 0
  • Default value of 32 preserved
  • 0 correctly disables body capture

DebugProbe.AspNetCore.Tests/Configuration/DebugProbeOptionsTests.cs

  • Added test: setting -1 throws ArgumentOutOfRangeException
  • Added test: setting 0 is valid and accepted correctly

Test Results

  • 2 new tests added — both passing ✅
  • 51 existing tests passing ✅
  • 3 pre-existing failures unrelated to this change (net10 PipeWriter compatibility issue)

@georgidhristov georgidhristov merged commit 6c3370d into DebugProbe:main Jun 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate MaxBodyCaptureSizeKb Configuration

2 participants