From bdf82698592acc3f27fa7a9aa612ea1ad7970437 Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Sun, 28 Jul 2024 22:37:54 -0400 Subject: fix(tvix/glue): coerce path argument to builtins.path to a path The "path" key in the arguments to builtins.path supports any path-coercible type (a string, a path...). Coerce it to a path in the argument rather than just requiring it already be one and throwing an error if it's not. This is... annoying to test, since it requires a file with known contents that's available in the build sandbox. But it works! Trust me! Fixes: b/412 Change-Id: I3c8e339bf344a208d5ed5990193942651f318745 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12053 Tested-by: BuildkiteCI Reviewed-by: flokli Autosubmit: aspen --- tvix/glue/src/builtins/import.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tvix/glue/src/builtins/import.rs b/tvix/glue/src/builtins/import.rs index a3273eca15dc..273be08ef7b6 100644 --- a/tvix/glue/src/builtins/import.rs +++ b/tvix/glue/src/builtins/import.rs @@ -116,6 +116,7 @@ mod import_builtins { use tokio::io::AsyncWriteExt; use tvix_castore::proto::node::Node; use tvix_castore::proto::FileNode; + use tvix_eval::builtins::coerce_value_to_path; use tvix_eval::generators::Gen; use tvix_eval::{generators::GenCo, ErrorKind, Value}; use tvix_eval::{FileType, NixContextElement, NixString}; @@ -128,9 +129,13 @@ mod import_builtins { ) -> Result { let args = args.to_attrs()?; let path = args.select_required("path")?; - let path = generators::request_force(&co, path.clone()) - .await - .to_path()?; + let path = + match coerce_value_to_path(&co, generators::request_force(&co, path.clone()).await) + .await? + { + Ok(path) => path, + Err(cek) => return Ok(cek.into()), + }; let name: String = if let Some(name) = args.select("name") { generators::request_force(&co, name.clone()) .await -- cgit 1.4.1