ZipArchive.IsZipFile fails on Linux: Cannot determine compressed stream type #661

Closed
opened 2026-01-29 22:15:26 +00:00 by claunia · 6 comments
Owner

Originally created by @Pyroluk on GitHub (Sep 27, 2024).

Originally assigned to: @Copilot on GitHub.

Hi,

Stream stream = File.OpenRead(zipFilePath);
var archive = ArchiveFactory.Open(stream);

Fails on Linux for zip files created on Windows using SharpCompress with:
System.InvalidOperationException : Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar

Same code runs fine on Windows though.

DotNet 8, SharpCompress 0.38.0

Originally created by @Pyroluk on GitHub (Sep 27, 2024). Originally assigned to: @Copilot on GitHub. Hi, ```cs Stream stream = File.OpenRead(zipFilePath); var archive = ArchiveFactory.Open(stream); ``` Fails on Linux for zip files created on Windows using SharpCompress with: `System.InvalidOperationException : Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar` Same code runs fine on Windows though. DotNet 8, SharpCompress 0.38.0
claunia added the bugup for grabs labels 2026-01-29 22:15:26 +00:00
Author
Owner

@adamhathcock commented on GitHub (Oct 28, 2025):

Probably need more detail here.

@adamhathcock commented on GitHub (Oct 28, 2025): Probably need more detail here.
Author
Owner

@Pyroluk commented on GitHub (Oct 29, 2025):

Can I send you my test zip + code which has the problem on ARM Linux? It is exceeding the size limit here of 25MB for attachments.

@Pyroluk commented on GitHub (Oct 29, 2025): Can I send you my test zip + code which has the problem on ARM Linux? It is exceeding the size limit here of 25MB for attachments.
Author
Owner

@adamhathcock commented on GitHub (Oct 29, 2025):

More code detail and archive type might point me in the right direction. ARM is a hint which I'll look at but in theory that should be fine. I'm using ARM MacOS

@adamhathcock commented on GitHub (Oct 29, 2025): More code detail and archive type might point me in the right direction. ARM is a hint which I'll look at but in theory that should be fine. I'm using ARM MacOS
Author
Owner

@Pyroluk commented on GitHub (Oct 29, 2025):

Found a smaller test zip:
eBayHtmlParser.zip

using SharpCompress.Archives;
...
Stream stream = File.OpenRead(eBayTestDatafilePath);
var archive = ArchiveFactory.Open(stream);

SharpCompress 0.40.0 fails with:
System.InvalidOperationException : Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar
Stack Trace:
at SharpCompress.Archives.ArchiveFactory.FindFactory[T](Stream stream)
at SharpCompress.Archives.ArchiveFactory.Open(Stream stream, ReaderOptions readerOptions)

This is running on an ARM64 chip with DotNet SDK Version: 9.0.306, Debian/Raspian GNU/Linux 11, 6.1.21-v8+ #1642 SMP PREEMPT aarch64.

@Pyroluk commented on GitHub (Oct 29, 2025): Found a smaller test zip: [eBayHtmlParser.zip](https://github.com/user-attachments/files/23209249/eBayHtmlParser.zip) ```cs using SharpCompress.Archives; ... Stream stream = File.OpenRead(eBayTestDatafilePath); var archive = ArchiveFactory.Open(stream); ``` SharpCompress 0.40.0 fails with: System.InvalidOperationException : Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar Stack Trace: at SharpCompress.Archives.ArchiveFactory.FindFactory[T](Stream stream) at SharpCompress.Archives.ArchiveFactory.Open(Stream stream, ReaderOptions readerOptions) This is running on an ARM64 chip with DotNet SDK Version: 9.0.306, Debian/Raspian GNU/Linux 11, 6.1.21-v8+ #1642 SMP PREEMPT aarch64.
Author
Owner

@Pyroluk commented on GitHub (Nov 28, 2025):

While testing the new release, it turned out the issue was simply a missing Git LFS installation in the CI test pipeline.
GitLab didn’t indicate anywhere that git pull with LFS had failed.

However, the problem in this library is still the misleading error message when the stream is actually empty:
"Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar"

@adamhathcock
Maybe we can add a check for an empty stream and throw a more specific error message in that case?

@Pyroluk commented on GitHub (Nov 28, 2025): While testing the new release, it turned out the issue was simply a missing Git LFS installation in the CI test pipeline. GitLab didn’t indicate anywhere that git pull with LFS had failed. However, the problem in this library is still the misleading error message when the stream is actually empty: "Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar" @adamhathcock Maybe we can add a check for an empty stream and throw a more specific error message in that case?
Author
Owner

@adamhathcock commented on GitHub (Nov 28, 2025):

It's going to be hard to detect that. I guess something can be added to detect reading zero bytes.

@adamhathcock commented on GitHub (Nov 28, 2025): It's going to be hard to detect that. I guess something can be added to detect reading zero bytes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#661