From 37835634e8009381d6747ab01cbfc4134d637654 Mon Sep 17 00:00:00 2001 From: Bob van der Linden Date: Wed, 30 Oct 2024 23:37:32 +0100 Subject: feat(tvix/glue): use InvalidHash for builtins.path Previously such errors showed up as: error[E006]: expected value of type 'sha256', but found a 'not a sha256' Now they show up as: error[E041]: Invalid hash: invalid encoded digest length '31' for algo sha256 This is consistent with the errors of `builtins.fetchurl`. Change-Id: Id11b26fc7951778640cc4e41b3bf23203eaf07df Reviewed-on: https://cl.tvl.fyi/c/depot/+/12719 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/glue/src/builtins/import.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'tvix/glue') diff --git a/tvix/glue/src/builtins/import.rs b/tvix/glue/src/builtins/import.rs index 5f495dcc623b..83b91165c09e 100644 --- a/tvix/glue/src/builtins/import.rs +++ b/tvix/glue/src/builtins/import.rs @@ -353,16 +353,7 @@ mod import_builtins { match nix_compat::nixhash::from_str(expected.to_str()?, Some("sha256")) { Ok(NixHash::Sha256(digest)) => Ok(digest), Ok(_) => unreachable!(), - Err(_e) => { - // TODO: a better error would be nice, we use - // DerivationError::InvalidOutputHash usually for derivation construction. - // This is not a derivation construction, should we move it outside and - // generalize? - Err(ErrorKind::TypeError { - expected: "sha256", - actual: "not a sha256", - }) - } + Err(e) => Err(ErrorKind::InvalidHash(e.to_string())), } }) }) -- cgit 1.4.1