Registry Mirror
Skip to content

Conversation

@makazeu

@makazeu makazeu commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Change BrotliStream to throw InvalidDataException instead of InvalidOperationException when decompression returns OperationStatus.InvalidData. This matches the existing Read documentation and the behavior of other compression streams.

Existing documented contract

Before this change, BrotliStream.Read(byte[], int, int) already documented InvalidDataException for invalid-format data:

/// <exception cref="System.IO.InvalidDataException">The data is in an invalid format.</exception>

The implementation instead threw InvalidOperationException for OperationStatus.InvalidData. This fix brings the implementation into line with that existing documented contract; it does not add or change the XML documentation.

Compression stream comparison

The following summarizes the current source behavior for detected format corruption, rather than underlying I/O failures or EOF/truncation policies:

Stream Exception for detected invalid compressed data
DeflateStream InvalidDataException
GZipStream InvalidDataException
ZLibStream InvalidDataException
ZstandardStream InvalidDataException
BrotliStream InvalidOperationException before this change; InvalidDataException afterward

Separate dictionary/configuration failures are unchanged: a zlib preset-dictionary requirement can throw ZLibException (an IOException subclass), while Zstandard's window-limit failure throws IOException and a dictionary mismatch throws InvalidDataException.

Built Brotli and passed the full Brotli test suite on Linux ARM64, including outer-loop tests; the regression theory was also confirmed to fail without the fix.

Addresses BROTLI-EXC-1. Relates to #134839.

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 8, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Thanks!

@rzikm

rzikm commented Dec 1, 2026

Copy link
Copy Markdown
Member

/ba-g test failures are unrelated

@rzikm
rzikm merged commit 64088bd into dotnet:main Dec 1, 2026
83 of 87 checks passed
@makazeu
makazeu deleted the fix-brotli-exc-1 branch December 1, 2026 14:31
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO.Compression community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants