refactor(tvix/store): mv *Err*::Invalid{Node,}DigestLen
There's other digests in the PathInfo structure, that also might have wrong digest lengths. Rename this to give some room for them, and update the error message a bit as we go. Change-Id: I06562664721156e658f2ed14ba1de907377d284b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9543 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu>
This commit is contained in:
parent
c67ab911eb
commit
7706a8f224
2 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
|||
// https://github.com/hyperium/tonic/issues/1056
|
||||
use nix_compat::store_path::{self, StorePath};
|
||||
use thiserror::Error;
|
||||
use tvix_castore::{proto as castorepb, B3Digest};
|
||||
use tvix_castore::{proto as castorepb, B3Digest, B3_LEN};
|
||||
|
||||
mod grpc_pathinfoservice_wrapper;
|
||||
|
||||
|
@ -31,8 +31,8 @@ pub enum ValidatePathInfoError {
|
|||
InvalidNodeName(Vec<u8>, store_path::Error),
|
||||
|
||||
/// The digest the (root) node refers to has invalid length.
|
||||
#[error("Invalid Digest length: {0}")]
|
||||
InvalidDigestLen(usize),
|
||||
#[error("Invalid Digest length: expected {}, got {}", B3_LEN, .0)]
|
||||
InvalidNodeDigestLen(usize),
|
||||
|
||||
/// The number of references in the narinfo.reference_names field does not match
|
||||
/// the number of references in the .references field.
|
||||
|
@ -84,7 +84,7 @@ impl PathInfo {
|
|||
Some(castorepb::node::Node::Directory(directory_node)) => {
|
||||
// ensure the digest has the appropriate size.
|
||||
if TryInto::<B3Digest>::try_into(directory_node.digest.clone()).is_err() {
|
||||
return Err(ValidatePathInfoError::InvalidDigestLen(
|
||||
return Err(ValidatePathInfoError::InvalidNodeDigestLen(
|
||||
directory_node.digest.len(),
|
||||
));
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl PathInfo {
|
|||
Some(castorepb::node::Node::File(file_node)) => {
|
||||
// ensure the digest has the appropriate size.
|
||||
if TryInto::<B3Digest>::try_into(file_node.digest.clone()).is_err() {
|
||||
return Err(ValidatePathInfoError::InvalidDigestLen(
|
||||
return Err(ValidatePathInfoError::InvalidNodeDigestLen(
|
||||
file_node.digest.len(),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ fn validate_no_node(
|
|||
digest: Bytes::new(),
|
||||
size: 0,
|
||||
},
|
||||
Err(ValidatePathInfoError::InvalidDigestLen(0));
|
||||
Err(ValidatePathInfoError::InvalidNodeDigestLen(0));
|
||||
"invalid digest length"
|
||||
)]
|
||||
#[test_case(
|
||||
|
@ -88,7 +88,7 @@ fn validate_directory(
|
|||
digest: Bytes::new(),
|
||||
..Default::default()
|
||||
},
|
||||
Err(ValidatePathInfoError::InvalidDigestLen(0));
|
||||
Err(ValidatePathInfoError::InvalidNodeDigestLen(0));
|
||||
"invalid digest length"
|
||||
)]
|
||||
#[test_case(
|
||||
|
|
Loading…
Reference in a new issue