Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Handle Unsupported Compression Methods in GZipStream Operations #192

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/SymbolCollector.Server/SymbolsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,17 @@ public async Task ValidateBatch(Guid batchId, ModelStateDictionary modelState, C
&& contentType == "gzip")
{
await using var gzipStream = new GZipStream(section.Body, CompressionMode.Decompress);
await gzipStream.CopyToAsync(outputStream);
try
{
await gzipStream.CopyToAsync(outputStream);
}
catch (InvalidDataException ex)
{
_logger.LogError(ex, "Unsupported compression method encountered.");
modelState.AddModelError("File", "Unsupported compression method.");
code = HttpStatusCode.UnsupportedMediaType;
return (null, null, code);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is right given there's a final return at the end for failure modes

Copy link
Member

Choose a reason for hiding this comment

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

Also CI is unhappy here, PR didn't take nullability into account:

/Users/runner/work/symbol-collector/symbol-collector/src/SymbolCollector.Server/SymbolsController.cs(337,28): error CS8619: Nullability of reference types in value of type '(string?, Stream?, HttpStatusCode? code)' doesn't match target type '(string fileName, Stream data, HttpStatusCode? code)'.

}
}
else
{
Expand Down
Loading