From 1c5bf366be915fd91c3d87f9b779f394505214a8 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 11 Oct 2023 19:12:10 +0200 Subject: refactor(tvix/nar-bridge): panic on inval PathInfo.NarInfo.NarSha256 Bump code.tvl.fyi/tvix/store/protos past cl/9649, where Validate() already ensures the NarSha256 has the correct size. Change-Id: I774668822f4d9dbd4dea47dde6e4745dc95e8e7f Reviewed-on: https://cl.tvl.fyi/c/depot/+/9665 Reviewed-by: edef Tested-by: BuildkiteCI --- tvix/nar-bridge/pkg/http/narinfo_get.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'tvix/nar-bridge/pkg/http') diff --git a/tvix/nar-bridge/pkg/http/narinfo_get.go b/tvix/nar-bridge/pkg/http/narinfo_get.go index acb80c7390..b3ee01fab5 100644 --- a/tvix/nar-bridge/pkg/http/narinfo_get.go +++ b/tvix/nar-bridge/pkg/http/narinfo_get.go @@ -65,13 +65,10 @@ func renderNarinfo( return fmt.Errorf("PathInfo doesn't contain Narinfo field") } - // extract the NARHash + // extract the NARHash. This must succeed, as Validate() did succeed. narHash, err := nixhash.FromHashTypeAndDigest(0x12, pathInfo.GetNarinfo().GetNarSha256()) if err != nil { - // TODO: replace with panic once we use cl/9649 - - log.WithError(err).Error("invalid NarHash in PathInfo") - return fmt.Errorf("invalid NarHash in PathInfo") + panic("must parse NarHash") } // add things to the lookup table, in case the same process didn't handle the NAR hash yet. -- cgit 1.4.1