about summary refs log tree commit diff
path: root/tvix/glue
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-07-29T02·37-0400
committerclbot <clbot@tvl.fyi>2024-07-31T20·18+0000
commitbdf82698592acc3f27fa7a9aa612ea1ad7970437 (patch)
treee5aa03a29f5f6af4f9d616fa63cb70db6be11ce6 /tvix/glue
parent13720d90bf1ad63deefda3e9e5ca3c187267c989 (diff)
fix(tvix/glue): coerce path argument to builtins.path to a path r/8434
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 <flokli@flokli.de>
Autosubmit: aspen <root@gws.fyi>
Diffstat (limited to 'tvix/glue')
-rw-r--r--tvix/glue/src/builtins/import.rs11
1 files 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<Value, ErrorKind> {
         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