Skip to content

Commit 7b2c118

Browse files
ldanilekConvex, Inc.
authored and
Convex, Inc.
committed
[components] fix returns validator (#27702)
currently we validate return values using the table mapping from the before the UDF runs. suppose the validator is `v.id("mytable")` and the UDF _creates_ the table `"mytable"` via an insert, and returns the ID. This would fail return value validation. GitOrigin-RevId: 638b92d8728494a0e04608416ab48767e5e68150
1 parent fcdc421 commit 7b2c118

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/isolate/src/environment/udf/async_syscall.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,6 @@ impl<RT: Runtime> AsyncSyscallProvider<RT> for DatabaseUdfEnvironment<RT> {
469469
let (_, called_component_id) = BootstrapComponentsModel::new(tx)
470470
.component_path_to_ids(function_path.component.clone())
471471
.await?;
472-
let table_mapping = tx.table_mapping().namespace(called_component_id.into());
473-
let virtual_table_mapping = tx
474-
.virtual_table_mapping()
475-
.namespace(called_component_id.into());
476472

477473
let path_and_args_result = ValidatedPathAndArgs::new_with_returns_validator(
478474
AllowedVisibility::PublicOnly,
@@ -533,6 +529,11 @@ impl<RT: Runtime> AsyncSyscallProvider<RT> for DatabaseUdfEnvironment<RT> {
533529
anyhow::bail!(ErrorMetadata::bad_request("UdfFailed", e.message));
534530
},
535531
};
532+
let tx = self.phase.tx()?;
533+
let table_mapping = tx.table_mapping().namespace(called_component_id.into());
534+
let virtual_table_mapping = tx
535+
.virtual_table_mapping()
536+
.namespace(called_component_id.into());
536537
if let Some(e) =
537538
returns_validator.check_output(&result, &table_mapping, &virtual_table_mapping)
538539
{

0 commit comments

Comments
 (0)