about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/default.nix2
-rw-r--r--tvix/store/protos/go.mod4
-rw-r--r--tvix/store/protos/go.sum4
-rw-r--r--tvix/store/protos/pathinfo.go49
4 files changed, 22 insertions, 37 deletions
diff --git a/tvix/default.nix b/tvix/default.nix
index 5fb7642b8755..827664894c76 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -108,7 +108,7 @@ in
   store-protos-go = pkgs.buildGoModule {
     name = "store-golang";
     src = depot.third_party.gitignoreSource ./store/protos;
-    vendorHash = "sha256-qPtEQTd1Vol8vhE10AdwTleTLfYS7xaOir3Ti4MJ+Vc=";
+    vendorHash = "sha256-WAYaIT3h3Cdvo1RB8T7DuoxeKvXfkq8vo/vdkhJQDs0=";
   };
 
   # Build the Rust documentation for publishing on docs.tvix.dev.
diff --git a/tvix/store/protos/go.mod b/tvix/store/protos/go.mod
index 34cc9c07acfa..d56e2d9bc1b4 100644
--- a/tvix/store/protos/go.mod
+++ b/tvix/store/protos/go.mod
@@ -3,13 +3,12 @@ module code.tvl.fyi/tvix/store/protos
 go 1.19
 
 require (
-	code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742
+	code.tvl.fyi/tvix/castore/protos v0.0.0-20231014122118-3fc2ade7dfb2
 	github.com/google/go-cmp v0.5.6
 	github.com/nix-community/go-nix v0.0.0-20231009143713-ebca3299475b
 	github.com/stretchr/testify v1.8.1
 	google.golang.org/grpc v1.51.0
 	google.golang.org/protobuf v1.31.0
-	lukechampine.com/blake3 v1.1.7
 )
 
 require (
@@ -23,4 +22,5 @@ require (
 	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
 	google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
+	lukechampine.com/blake3 v1.1.7 // indirect
 )
diff --git a/tvix/store/protos/go.sum b/tvix/store/protos/go.sum
index dd7d9bf0454d..c412d838e289 100644
--- a/tvix/store/protos/go.sum
+++ b/tvix/store/protos/go.sum
@@ -1,6 +1,6 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742 h1:x7LsxggggaN3acnCMNDO5LZLAV+A+rZ+R8TXzr+Lgsk=
-code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742/go.mod h1:Ejhyvc0dJUWQMxtJxddfFuAF5N8IKIO94q5CP4czY8Y=
+code.tvl.fyi/tvix/castore/protos v0.0.0-20231014122118-3fc2ade7dfb2 h1:Z5GS8OUe7L/hKDbb1amArY7QgX0DSD5xaBwWxmh4H3Y=
+code.tvl.fyi/tvix/castore/protos v0.0.0-20231014122118-3fc2ade7dfb2/go.mod h1:hj0y8RPthqn1QPj8u2jFe2vzH7NouUoclrwo1/CSbuc=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
diff --git a/tvix/store/protos/pathinfo.go b/tvix/store/protos/pathinfo.go
index 9b51b5266cdc..8c0b94f200c1 100644
--- a/tvix/store/protos/pathinfo.go
+++ b/tvix/store/protos/pathinfo.go
@@ -57,55 +57,40 @@ func (p *PathInfo) Validate() (*storepath.StorePath, error) {
 		return nil, fmt.Errorf("root node must be set")
 	}
 
-	// for all three node types, ensure the name properly parses to a store path,
-	// and in case it refers to a digest, ensure it has the right length.
+	if err := rootNode.Validate(); err != nil {
+		return nil, fmt.Errorf("root node failed validation: %w", err)
+	}
 
-	var storePath *storepath.StorePath
-	var err error
+	// for all three node types, ensure the name properly parses to a store path.
+	// This is a stricter check as the ones already performed in the rootNode.Validate() call.
+	var rootNodeName []byte
 
 	if node := rootNode.GetDirectory(); node != nil {
-		if len(node.Digest) != 32 {
-			return nil, fmt.Errorf("invalid digest size for %s, expected %d, got %d", node.Name, 32, len(node.Digest))
-		}
-
-		storePath, err = storepath.FromString(string(node.GetName()))
-
-		if err != nil {
-			return nil, fmt.Errorf("unable to parse %s as StorePath: %w", node.Name, err)
-		}
-
+		rootNodeName = node.GetName()
 	} else if node := rootNode.GetFile(); node != nil {
-		if len(node.Digest) != 32 {
-			return nil, fmt.Errorf("invalid digest size for %s, expected %d, got %d", node.Name, 32, len(node.Digest))
-		}
-
-		storePath, err = storepath.FromString(string(node.GetName()))
-		if err != nil {
-			return nil, fmt.Errorf("unable to parse %s as StorePath: %w", node.Name, err)
-		}
-
+		rootNodeName = node.GetName()
 	} else if node := rootNode.GetSymlink(); node != nil {
-		storePath, err = storepath.FromString(string(node.GetName()))
-
-		if err != nil {
-			return nil, fmt.Errorf("unable to parse %s as StorePath: %w", node.Name, err)
-		}
-
+		rootNodeName = node.GetName()
 	} else {
-		// this would only happen if we introduced a new type
+		// already caught by rootNode.Validate()
 		panic("unreachable")
 	}
 
+	storePath, err := storepath.FromString(string(rootNodeName))
+	if err != nil {
+		return nil, fmt.Errorf("unable to parse root node name %s as StorePath: %w", rootNodeName, err)
+	}
+
 	// If the Deriver field is populated, ensure it parses to a StorePath.
 	// We can't check for it to *not* end with .drv, as the .drv files produced by
 	// recursive Nix end with multiple .drv suffixes, and only one is popped when
 	// converting to this field.
 	if p.Deriver != nil {
-		storePath := storepath.StorePath{
+		deriverStorePath := storepath.StorePath{
 			Name:   string(p.Deriver.GetName()),
 			Digest: p.Deriver.GetDigest(),
 		}
-		if err := storePath.Validate(); err != nil {
+		if err := deriverStorePath.Validate(); err != nil {
 			return nil, fmt.Errorf("invalid deriver field: %w", err)
 		}
 	}