Skip to content

Fixes request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors,#347

Merged
niemyjski merged 5 commits intomainfrom
feature/upgrade-workflows-request-info
Mar 25, 2026
Merged

Fixes request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors,#347
niemyjski merged 5 commits intomainfrom
feature/upgrade-workflows-request-info

Conversation

@niemyjski
Copy link
Copy Markdown
Member

@niemyjski niemyjski commented Mar 25, 2026

This PR updates request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors, and modernizes build configuration to use the SDK from global.json.

Changes:

  1. Gate POST body/form collection behind an isUnhandledError flag in Web + ASP.NET Core request collectors and propagate that flag from platform plugins.
  2. Add ASP.NET Core request-info unit tests and add the ASP.NET Core platform dependency to the test project.
  3. Update build tooling: bump global.json SDK, tweak common props, and refresh GitHub Actions workflow steps.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors, and modernizes build configuration to use the SDK from global.json.

Changes:

  • Gate POST body/form collection behind an isUnhandledError flag in Web + ASP.NET Core request collectors and propagate that flag from platform plugins.
  • Add ASP.NET Core request-info unit tests and add the ASP.NET Core platform dependency to the test project.
  • Update build tooling: bump global.json SDK, tweak common props, and refresh GitHub Actions workflow steps.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/Exceptionless.Tests/Platforms/AspNetCoreRequestInfoTests.cs Adds coverage for ASP.NET Core request body behavior with handled vs unhandled errors.
test/Exceptionless.Tests/Exceptionless.Tests.csproj Adds AspNetCore platform reference + ASP.NET Core Http package for tests.
src/Platforms/Exceptionless.WebApi/RequestInfoCollector.cs Adds isUnhandledError parameter (POST collection still not implemented).
src/Platforms/Exceptionless.WebApi/ExceptionlessWebApiPlugin.cs Passes IsUnhandledError when collecting request info.
src/Platforms/Exceptionless.WebApi/ExceptionlessWebApiExtensions.cs Updates WebApi GetRequestInfo API to accept isUnhandledError.
src/Platforms/Exceptionless.Web/RequestInfoCollector.cs Gates POST data collection behind isUnhandledError and reorders form/body logic.
src/Platforms/Exceptionless.Web/ExceptionlessWebPlugin.cs Passes IsUnhandledError when collecting request info.
src/Platforms/Exceptionless.Web/ExceptionlessWebExtensions.cs Updates Web GetRequestInfo APIs to accept isUnhandledError.
src/Platforms/Exceptionless.AspNetCore/RequestInfoCollector.cs Gates POST data collection behind isUnhandledError and reorders form/body logic.
src/Platforms/Exceptionless.AspNetCore/ExceptionlessExtensions.cs Updates AspNetCore GetRequestInfo API to accept isUnhandledError.
src/Platforms/Exceptionless.AspNetCore/ExceptionlessAspNetCorePlugin.cs Passes IsUnhandledError when collecting request info.
samples/Exceptionless.SampleAspNetCore/Controllers/ValuesController.cs Minor formatting changes around catch blocks.
global.json Updates the pinned .NET SDK version.
build/common.props Enables Windows targeting in the build properties.
.github/workflows/build-windows.yml Updates workflow env + .NET setup to use global.json.
.github/workflows/build-osx.yml Updates workflow env + .NET setup to use global.json.
.github/workflows/build-linux.yml Updates workflow env + .NET setup to use global.json.
Comments suppressed due to low confidence (2)

src/Platforms/Exceptionless.AspNetCore/RequestInfoCollector.cs:69

  • ContentLength.GetValueOrDefault() treats a missing Content-Length header as 0, and since the contentLength == 0 branch returns early this will report an empty post and skip reading the body (or form) for chunked requests / unknown-length bodies. Consider handling ContentLength == null separately (e.g., read up to MAX_BODY_SIZE), and/or check HasFormContentType before the contentLength == 0 early-return.
            long contentLength = context.Request.ContentLength.GetValueOrDefault();
            if(contentLength == 0) {
                string message = "Content-length was zero, empty post.";
                log.Debug(message);
                return message;
            }

src/Platforms/Exceptionless.Web/RequestInfoCollector.cs:82

  • The contentLength == 0 early-return now happens before checking Request.Form. If ContentLength is 0/unknown but form fields are available, this will incorrectly report an empty post and skip collecting the form. Consider checking Request.Form.Count before the contentLength == 0 guard, or treating 0 as “unknown length” and falling back to a bounded read (MAX_BODY_SIZE).
            int contentLength = context.Request.ContentLength;
            if (contentLength == 0) {
                string message = "Content-length was zero, empty post.";
                log.Debug(message);
                return message;
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Restores the request body stream position after accessing form data in AspNetCore and Web platforms. This commit also updates the test project to target .NET 10 and migrates the copyright notice to use a dynamic year.
@niemyjski niemyjski requested a review from Copilot March 25, 2026 13:15
@niemyjski niemyjski changed the title Feature/upgrade workflows request info Fixes request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors, Mar 25, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<EnableWindowsTargeting>true</EnableWindowsTargeting>

<Copyright>Copyright (c) 2025 Exceptionless. All rights reserved.</Copyright>
<Copyright>Copyright © $([System.DateTime]::Now.ToString(yyyy)) Exceptionless. All rights reserved.</Copyright>
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MSBuild property function call uses Now.ToString(yyyy) without quoting the format string. MSBuild property functions typically require string arguments to be quoted (e.g., ToString('yyyy')), otherwise the argument may be treated as an empty/unresolved expression and not yield the intended year.

Suggested change
<Copyright>Copyright © $([System.DateTime]::Now.ToString(yyyy)) Exceptionless. All rights reserved.</Copyright>
<Copyright>Copyright © $([System.DateTime]::Now.ToString('yyyy')) Exceptionless. All rights reserved.</Copyright>

Copilot uses AI. Check for mistakes.
return context.Request.Form.ToDictionary(exclusionList);
}

int maxDataToRead = contentLength == 0 ? MAX_BODY_SIZE : contentLength;
@niemyjski niemyjski merged commit 1129ee2 into main Mar 25, 2026
6 of 8 checks passed
@niemyjski niemyjski deleted the feature/upgrade-workflows-request-info branch March 25, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants