diff --git a/crates/isolate/src/environment/helpers/validation.rs b/crates/isolate/src/environment/helpers/validation.rs index a1aa2ba5..d7b71cb8 100644 --- a/crates/isolate/src/environment/helpers/validation.rs +++ b/crates/isolate/src/environment/helpers/validation.rs @@ -316,41 +316,31 @@ impl ValidatedPathAndArgs { }, } - let maybe_path = match public_path.clone() { + let path = match public_path.clone() { PublicFunctionPath::RootExport(path) => { - match ComponentsModel::new(tx) + let path = ComponentsModel::new(tx) .resolve_public_export_path(path) - .await? - { - Some(path) => { - let (_, component) = BootstrapComponentsModel::new(tx) - .component_path_to_ids(path.component.clone()) - .await?; - Some(ResolvedComponentFunctionPath { - component, - udf_path: path.udf_path, - component_path: Some(path.component), - }) - }, - None => None, + .await?; + let (_, component) = BootstrapComponentsModel::new(tx) + .component_path_to_ids(path.component.clone()) + .await?; + ResolvedComponentFunctionPath { + component, + udf_path: path.udf_path, + component_path: Some(path.component), } }, PublicFunctionPath::Component(path) => { let (_, component) = BootstrapComponentsModel::new(tx) .component_path_to_ids(path.component.clone()) .await?; - Some(ResolvedComponentFunctionPath { + ResolvedComponentFunctionPath { component, udf_path: path.udf_path, component_path: Some(path.component), - }) + } }, - PublicFunctionPath::ResolvedComponent(path) => Some(path), - }; - let Some(path) = maybe_path else { - return Ok(Err(JsError::from_message(missing_or_internal_error( - public_path.clone(), - )?))); + PublicFunctionPath::ResolvedComponent(path) => path, }; let udf_version = match udf_version(&path, tx).await? { diff --git a/crates/model/src/components/mod.rs b/crates/model/src/components/mod.rs index c012fc0c..47a5adea 100644 --- a/crates/model/src/components/mod.rs +++ b/crates/model/src/components/mod.rs @@ -223,29 +223,34 @@ impl<'a, RT: Runtime> ComponentsModel<'a, RT> { pub async fn resolve_public_export_path( &mut self, path: ExportPath, - ) -> anyhow::Result> { + ) -> anyhow::Result { let root_definition = BootstrapComponentsModel::new(self.tx) .load_definition(ComponentDefinitionId::Root) .await?; // Legacy path: If components aren't enabled, just resolve export paths directly // to UDF paths. if root_definition.is_none() { - return Ok(Some(CanonicalizedComponentFunctionPath { + return Ok(CanonicalizedComponentFunctionPath { component: ComponentPath::root(), udf_path: path.into(), - })); + }); } let path_components = path.components(); let resource = self .resolve_export(ComponentId::Root, &path_components) .await?; let Some(resource) = resource else { - return Ok(None); + // In certain cases non-exported functions can be called, e.g. + // system auth can call internal functions. + return Ok(CanonicalizedComponentFunctionPath { + component: ComponentPath::root(), + udf_path: path.into(), + }); }; let Resource::Function(path) = resource else { anyhow::bail!("Expected a function"); }; - Ok(Some(path)) + Ok(path) } pub async fn preload_resources(