Treat a missing notes ref as no attestations - #443
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Thanks for the fix @arpitjain099 while I've confirmed that the bug is real, it is coming from the collector upstream and it is affecting other projects that collect attestations from git notes. I'll fix it there and pull the fixed release. |
|
Makes sense, upstream is the better place for it. Happy to close this whenever you have the release pinned, or leave it as a stopgap, your call. One detail worth carrying over: |
Fixes #435.
A repository that has never been attested has no
refs/notes/commits, and the fetch for it fails with go-git's "couldn't find remote ref". BothGetRevisionVSAandGetRevisionProvenanceturn that into a hard error, sostatusand the attest flow refuse to run on a fresh repository, and the genesis attestation that would create the ref can never be written. The workaround in the issue is to seed the ref by hand.Both call sites now treat that specific failure as an empty attestation set, which is what it means, and stop retrying it, since sleeping between attempts cannot make a ref appear.
One wrinkle worth flagging.
errors.Isalone is not enough here. The collector reaches the notes ref throughvcslocator.CopyFileGroup, which collects per-locator failures into avcslocator.ErrorList. That type implementsError()but notUnwrap, so the go-git error is not reachable through the chain on that path and only the rendered message survives. The check does the typed comparison first and falls back to the message, and the test covers both shapes plus an unrelated failure that must still be reported. IfErrorListgrows anUnwrap() []errorupstream, the string half can go.go test ./pkg/...passes.