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

archive/tar: restore Go 1.9 error strings? #22740

Closed
rsc opened this issue Nov 15, 2017 · 1 comment
Closed

archive/tar: restore Go 1.9 error strings? #22740

rsc opened this issue Nov 15, 2017 · 1 comment

Comments

@rsc
Copy link
Contributor

rsc commented Nov 15, 2017

$ cd go1.9/src/archive/tar
$ g tar:
common.go:205:		return nil, errors.New("tar: FileInfo is nil")
common.go:232:		return nil, fmt.Errorf("archive/tar: sockets not supported")
common.go:234:		return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
reader.go:22:	ErrHeader = errors.New("archive/tar: invalid tar header")
writer.go:23:	ErrWriteTooLong    = errors.New("archive/tar: write too long")
writer.go:24:	ErrFieldTooLong    = errors.New("archive/tar: header field too long")
writer.go:25:	ErrWriteAfterClose = errors.New("archive/tar: write after close")
writer.go:26:	errInvalidHeader   = errors.New("archive/tar: header field too long or contains invalid values")
writer.go:51:		tw.err = fmt.Errorf("archive/tar: missed writing %d bytes", tw.nb)
$ 

CL 55650 changed these, saying “Also, consistently use the "tar: " prefix for errors.” And sure enough:

$ cd ~/go/src/archive/tar
$ g tar:
common.go:31:	ErrHeader          = errors.New("tar: invalid tar header")
common.go:32:	ErrWriteTooLong    = errors.New("tar: write too long")
common.go:33:	ErrFieldTooLong    = errors.New("tar: header field too long")
common.go:34:	ErrWriteAfterClose = errors.New("tar: write after close")
common.go:35:	errMissData        = errors.New("tar: sparse file references non-existent data")
common.go:36:	errUnrefData       = errors.New("tar: sparse file contains unreferenced data")
common.go:37:	errWriteHole       = errors.New("tar: write non-NUL byte in sparse hole")
common.go:43:	const prefix = "tar: cannot encode header"
common.go:583:		return errors.New("tar: invalid sparse holes")
common.go:701:		return nil, errors.New("tar: FileInfo is nil")
common.go:728:		return nil, fmt.Errorf("tar: sockets not supported")
common.go:730:		return nil, fmt.Errorf("tar: unknown file mode %v", fm)
writer.go:56:		return fmt.Errorf("tar: missed writing %d bytes", nb)
writer_test.go:272:		//	gnutar: Substituting `.' for empty member name
writer_test.go:274:		//	gnutar: Substituting `.' for empty member name
$ 

We know that changing error strings breaks client code (even if you think it shouldn't, we know it does). I understand wanting them to be consistent, but they were consistently archive/tar before - there was just one that didn't have the archive/ prefix. Why are we changing N-1 errors instead of 1 error?

/cc @dsnet

@rsc rsc added this to the Go1.10 milestone Nov 15, 2017
@gopherbot
Copy link

Change https://golang.org/cl/77933 mentions this issue: archive/tar: change error prefix

@golang golang locked and limited conversation to collaborators Nov 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants