Skip to content

archive/zip: return clearer errors #53070

Description

@mbrackeantidot

Currently, the errors returned in archive/zip are often not very clear due to the following issues:

  • They lack documentation (e.g. ErrAlgorithm in reader.go on lines 25 and 190).
  • They are too generic to provide an actionable error message to the end user (e.g. ErrFormat in reader.go on lines 24 and 238).
  • They are not stored in a variable (e.g. the error in writer.go on line 512).
  • One return in particular seems to violate the documentation of io.Reader: on line 245 of reader.go we return 0, io.ErrUnexpectedEOF. But the documentation of io.Reader states "When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read." So we should return n instead of 0.

I would like to replace the current errors in archive/zip with actionable, clearly documented variables, like the ones we see in io/io.go. If you accept the general outline of the proposal, I can make a detailed design doc containing every error I would like to create. A design doc seems important given the number of public-facing changes that are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions