You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code for reading zip read,err := zip.OpenReader("filename.zip")
In cases of error due to headers etc, it's very difficult to debug without changing the golang source code(And adding logs there). The error just states "zip: not a valid zip file".
It would be beneficial to know why the zip is not valid. So adding a proposal to make the errors here more clear with exact reason for the zip file being invalid
The text was updated successfully, but these errors were encountered:
what sort of API (custom error type?) is being proposed here?
dmitshur
changed the title
proposal: archive/zip: : Enhancing ErrFormat error string with more granular details of failure
proposal: archive/zip: enhance ErrFormat error string with more granular details of failure
Nov 23, 2023
@niksw7, to provide a clearer understanding of the issue, it's advisable to utilize the unzip utility to decompress the file. There are multiple approaches to replicating the error, such as creating an empty file and attempting to read the zip file.
% go run main.go
zip: not a valid zip file
exit status 1
% unzip foo.zip
Archive: foo.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of foo.zip or
foo.zip.zip, and cannot find foo.zip.ZIP, period.
@nnzv ,
I am speaking from the archive/zip package error messages.
There are lot of use cases, where from a golang code we have to copy few files from zip. So a more clear error message would help in debugging. I will try to add few test cases for it to ellaborate
Proposal Details
The current code for reading zip
read,err := zip.OpenReader("filename.zip")
In cases of error due to headers etc, it's very difficult to debug without changing the golang source code(And adding logs there). The error just states "zip: not a valid zip file".
It would be beneficial to know why the zip is not valid. So adding a proposal to make the errors here more clear with exact reason for the zip file being invalid
The text was updated successfully, but these errors were encountered: