-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: mod verify fails if directory entries are in zip file #53448
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
Comments
how were the zip files made? |
@seankhliao Thanks for pointing the direction. The zip file (https://proxy.golang.org/go.felesatra.moe/cloudflare/@v/v0.3.0.zip) contains an unexpected folder entry (
|
go mod verify
fails immediately after fresh go mod download
It seems to me that the bug here is that Unfortunately, there is no way in general to make Ideally I think we should change |
(We could, independently, also skip directories explicitly in |
I don't know if there's a formal reference for zip file format, but my experience is that the dir entry is commonly present. The zip file in question I constructed using |
@darkfeline, the zip format is documented in https://go.dev/ref/mod#zip-files, and is not the same as what is produced by That reference does currently state that “Empty directories (entries with paths ending with a slash) may be included in module zip files but are not extracted. The go command does not include empty directories in zip files it creates.” However, in light of the checksum mismatches caused by those entries, it seems clear to me that it needs to be revised. |
I'm talking about the zip format generally, e.g., whether it is considered standard practice or correct to include dir entries. Because that is what both Hypothetically then, Go recommending zip archives not containing such dir entries would mean Go is recommending improper/incorrect zip archives to be used. Hence my open question on a formal reference for zip file format. I might be preaching to the choir, but my opinion is that Go should probably explicitly tolerate zip archives with such dir entries assuming that de facto everyone expects zip archives to include them, even if Go recommends not including them. This is in response to your above comment:
|
That's fair. I think we'd still need to adjust the checksumming, though, and that will still invalidate all existing modules with zipfiles containing directory entries. 🤷♂️ |
This issue is currently labeled as early-in-cycle for Go 1.20. |
I looked into this a bit with @bcmills. A few notes.
This problem seems like a fairly low priority, but that would be the plan. |
@darkfeline are you using your own code to generate the modules, or are you using some broadly available tool? If the latter we'd want to notify the author. Thanks. |
I am using |
This issue is currently labeled as early-in-cycle for Go 1.21. |
This issue is currently labeled as early-in-cycle for Go 1.22. |
I think this needs to wait for at least Go 1.23, so that Go toolchains that don't enforce strict toolchain bounds are no longer supported when the hashes change. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I think so
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go mod verify
fails immediately on freshly downloaded modules. This can be reproduced with a hermetic Docker setup:Dockerfile:
go.mod:
main.go:
I suspect there's something weird about the module zip files I build for
go.felesatra.moe/cloudflare
, but I'm not sure where to start looking.Also, it seems strange how
go mod verify
could fail. If I understand correctly, it's checking that the downloaded zip and the unpacked dir haven't been modified, and given the above hermetic Docker reproduction I don't see how that could be the case.What did you expect to see?
No error
What did you see instead?
go mod verify
says the downloaded dir has been modifiedThe text was updated successfully, but these errors were encountered: