Skip to content

Commit 09ba23c

Browse files
Sujay JayakarConvex, Inc.
Sujay Jayakar
authored and
Convex, Inc.
committed
feat(components): Rename ValidatedUdfPathAndArgs to ValidatedPathAndArgs (#25680)
GitOrigin-RevId: 0d5153e585d61919531f266bb6931333254cb9bc
1 parent 3b2b10a commit 09ba23c

File tree

16 files changed

+86
-86
lines changed

16 files changed

+86
-86
lines changed

crates/application/src/application_function_runner/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ use isolate::{
113113
ModuleLoader,
114114
UdfOutcome,
115115
ValidatedHttpPath,
116-
ValidatedUdfPathAndArgs,
116+
ValidatedPathAndArgs,
117117
};
118118
use keybroker::{
119119
Identity,
@@ -269,7 +269,7 @@ impl<RT: Runtime> FunctionRouter<RT> {
269269
pub(crate) async fn execute_query_or_mutation(
270270
&self,
271271
tx: Transaction<RT>,
272-
path_and_args: ValidatedUdfPathAndArgs,
272+
path_and_args: ValidatedPathAndArgs,
273273
udf_type: UdfType,
274274
journal: QueryJournal,
275275
context: ExecutionContext,
@@ -289,7 +289,7 @@ impl<RT: Runtime> FunctionRouter<RT> {
289289
pub(crate) async fn execute_action(
290290
&self,
291291
tx: Transaction<RT>,
292-
path_and_args: ValidatedUdfPathAndArgs,
292+
path_and_args: ValidatedPathAndArgs,
293293
log_line_sender: mpsc::UnboundedSender<LogLine>,
294294
context: ExecutionContext,
295295
) -> anyhow::Result<ActionOutcome> {
@@ -319,7 +319,7 @@ impl<RT: Runtime> FunctionRouter<RT> {
319319
async fn function_runner_execute(
320320
&self,
321321
mut tx: Transaction<RT>,
322-
path_and_args: ValidatedUdfPathAndArgs,
322+
path_and_args: ValidatedPathAndArgs,
323323
udf_type: UdfType,
324324
journal: QueryJournal,
325325
context: ExecutionContext,
@@ -668,7 +668,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
668668

669669
let identity = tx.inert_identity();
670670
let start = self.runtime.monotonic_now();
671-
let validate_result = ValidatedUdfPathAndArgs::new(
671+
let validate_result = ValidatedPathAndArgs::new(
672672
caller.allowed_visibility(),
673673
&mut tx,
674674
path.clone(),
@@ -982,7 +982,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
982982
anyhow::bail!(unauthorized_error("mutation"));
983983
}
984984
let identity = tx.inert_identity();
985-
let validate_result = ValidatedUdfPathAndArgs::new(
985+
let validate_result = ValidatedPathAndArgs::new(
986986
allowed_visibility,
987987
&mut tx,
988988
path.clone(),
@@ -1147,7 +1147,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11471147
.database
11481148
.begin_with_usage(identity.clone(), usage_tracking)
11491149
.await?;
1150-
let validate_result = ValidatedUdfPathAndArgs::new(
1150+
let validate_result = ValidatedPathAndArgs::new(
11511151
caller.allowed_visibility(),
11521152
&mut tx,
11531153
path.clone(),

crates/application/src/cache/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use futures::{
5252
use isolate::{
5353
FunctionOutcome,
5454
UdfOutcome,
55-
ValidatedUdfPathAndArgs,
55+
ValidatedPathAndArgs,
5656
};
5757
use keybroker::Identity;
5858
use lru::LruCache;
@@ -449,7 +449,7 @@ impl<RT: Runtime> CacheManager<RT> {
449449
// checks are transactional with running the query. This is safe because we will
450450
// never serve a result based of a stale visibility check since the data read as
451451
// part of the visibility check is part of the ReadSet for this query.
452-
let validate_result = ValidatedUdfPathAndArgs::new(
452+
let validate_result = ValidatedPathAndArgs::new(
453453
allowed_visibility,
454454
&mut tx,
455455
path.clone(),

crates/function_runner/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use futures::channel::mpsc;
3535
use isolate::{
3636
ActionCallbacks,
3737
FunctionOutcome,
38-
ValidatedUdfPathAndArgs,
38+
ValidatedPathAndArgs,
3939
};
4040
use keybroker::Identity;
4141
use model::environment_variables::types::{
@@ -62,7 +62,7 @@ pub mod server;
6262
pub trait FunctionRunner<RT: Runtime>: Send + Sync + 'static {
6363
async fn run_function(
6464
&self,
65-
path_and_args: ValidatedUdfPathAndArgs,
65+
path_and_args: ValidatedPathAndArgs,
6666
udf_type: UdfType,
6767
identity: Identity,
6868
ts: RepeatableTimestamp,

crates/function_runner/src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use isolate::{
7676
ConcurrencyLimiter,
7777
FunctionOutcome,
7878
IsolateConfig,
79-
ValidatedUdfPathAndArgs,
79+
ValidatedPathAndArgs,
8080
};
8181
use keybroker::{
8282
Identity,
@@ -332,7 +332,7 @@ impl<RT: Runtime, S: StorageForInstance<RT>> FunctionRunnerCore<RT, S> {
332332
action_callbacks: Arc<dyn ActionCallbacks>,
333333
fetch_client: Arc<dyn FetchClient>,
334334
log_line_sender: Option<mpsc::UnboundedSender<LogLine>>,
335-
path_and_args: ValidatedUdfPathAndArgs,
335+
path_and_args: ValidatedPathAndArgs,
336336
udf_type: UdfType,
337337
identity: Identity,
338338
ts: RepeatableTimestamp,
@@ -504,7 +504,7 @@ impl<RT: Runtime> FunctionRunner<RT> for InProcessFunctionRunner<RT> {
504504
#[minitrace::trace]
505505
async fn run_function(
506506
&self,
507-
path_and_args: ValidatedUdfPathAndArgs,
507+
path_and_args: ValidatedPathAndArgs,
508508
udf_type: UdfType,
509509
identity: Identity,
510510
ts: RepeatableTimestamp,

crates/isolate/src/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ use crate::{
144144
},
145145
helpers::validation::{
146146
ValidatedHttpPath,
147-
ValidatedUdfPathAndArgs,
147+
ValidatedPathAndArgs,
148148
},
149149
schema::SchemaEnvironment,
150150
udf::DatabaseUdfEnvironment,
@@ -346,7 +346,7 @@ pub trait ActionCallbacks: Send + Sync {
346346
}
347347

348348
pub struct UdfRequest<RT: Runtime> {
349-
pub path_and_args: ValidatedUdfPathAndArgs,
349+
pub path_and_args: ValidatedPathAndArgs,
350350
pub udf_type: UdfType,
351351
pub identity: InertIdentity,
352352
pub transaction: Transaction<RT>,
@@ -372,7 +372,7 @@ pub struct ActionRequest<RT: Runtime> {
372372
#[derive(Clone, PartialEq, Eq)]
373373
#[cfg_attr(any(test, feature = "testing"), derive(Debug))]
374374
pub struct ActionRequestParams {
375-
pub path_and_args: ValidatedUdfPathAndArgs,
375+
pub path_and_args: ValidatedPathAndArgs,
376376
}
377377

378378
pub struct EnvironmentData<RT: Runtime> {
@@ -654,7 +654,7 @@ impl<RT: Runtime> IsolateClient<RT> {
654654
pub async fn execute_udf(
655655
&self,
656656
udf_type: UdfType,
657-
path_and_args: ValidatedUdfPathAndArgs,
657+
path_and_args: ValidatedPathAndArgs,
658658
transaction: Transaction<RT>,
659659
journal: QueryJournal,
660660
context: ExecutionContext,
@@ -755,7 +755,7 @@ impl<RT: Runtime> IsolateClient<RT> {
755755
#[minitrace::trace]
756756
pub async fn execute_action(
757757
&self,
758-
path_and_args: ValidatedUdfPathAndArgs,
758+
path_and_args: ValidatedPathAndArgs,
759759
transaction: Transaction<RT>,
760760
action_callbacks: Arc<dyn ActionCallbacks>,
761761
fetch_client: Arc<dyn FetchClient>,

crates/isolate/src/environment/action/outcome.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
SyscallTrace,
3232
},
3333
http_action::HttpActionRequestHead,
34-
ValidatedUdfPathAndArgs,
34+
ValidatedPathAndArgs,
3535
};
3636

3737
#[derive(Debug, Clone)]
@@ -77,7 +77,7 @@ impl ActionOutcome {
7777
result,
7878
syscall_trace,
7979
}: ActionOutcomeProto,
80-
path_and_args: ValidatedUdfPathAndArgs,
80+
path_and_args: ValidatedPathAndArgs,
8181
identity: InertIdentity,
8282
) -> anyhow::Result<Self> {
8383
let result = result.ok_or_else(|| anyhow::anyhow!("Missing result"))?;
@@ -217,7 +217,7 @@ mod tests {
217217
use super::{
218218
ActionOutcome,
219219
ActionOutcomeProto,
220-
ValidatedUdfPathAndArgs,
220+
ValidatedPathAndArgs,
221221
};
222222

223223
proptest! {
@@ -232,7 +232,7 @@ mod tests {
232232
let arguments = udf_outcome.arguments.clone();
233233
let version = udf_outcome.udf_server_version.clone();
234234
let identity = udf_outcome_clone.identity.clone();
235-
let path_and_args = ValidatedUdfPathAndArgs::new_for_tests(
235+
let path_and_args = ValidatedPathAndArgs::new_for_tests(
236236
udf_path,
237237
arguments,
238238
version

crates/isolate/src/environment/helpers/outcome.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
},
1313
udf::outcome::UdfOutcome,
1414
},
15-
ValidatedUdfPathAndArgs,
15+
ValidatedPathAndArgs,
1616
};
1717

1818
/// A `UdfOutcome` represents a successful execution of a developer's function
@@ -31,7 +31,7 @@ pub enum FunctionOutcome {
3131
impl FunctionOutcome {
3232
pub fn from_proto(
3333
FunctionOutcomeProto { outcome }: FunctionOutcomeProto,
34-
path_and_args: ValidatedUdfPathAndArgs,
34+
path_and_args: ValidatedPathAndArgs,
3535
identity: InertIdentity,
3636
) -> anyhow::Result<Self> {
3737
let outcome = outcome.ok_or_else(|| anyhow::anyhow!("Missing outcome"))?;

crates/isolate/src/environment/helpers/validation.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,28 +175,28 @@ async fn udf_version<RT: Runtime>(
175175
/// - Checking the args size.
176176
/// - Checking that the args pass validation.
177177
///
178-
/// This should only be constructed via `ValidatedUdfPath::new` to use the type
179-
/// system to enforce that validation is never skipped.
178+
/// This should only be constructed via `ValidatedPathAndArgs::new` to use the
179+
/// type system to enforce that validation is never skipped.
180180
#[derive(Clone, Eq, PartialEq)]
181181
#[cfg_attr(any(test, feature = "testing"), derive(Debug))]
182-
pub struct ValidatedUdfPathAndArgs {
182+
pub struct ValidatedPathAndArgs {
183183
path: CanonicalizedComponentFunctionPath,
184184
args: ConvexArray,
185185
// Not set for system modules.
186186
npm_version: Option<Version>,
187187
}
188188

189189
#[cfg(any(test, feature = "testing"))]
190-
impl Arbitrary for ValidatedUdfPathAndArgs {
190+
impl Arbitrary for ValidatedPathAndArgs {
191191
type Parameters = ();
192192

193-
type Strategy = impl Strategy<Value = ValidatedUdfPathAndArgs>;
193+
type Strategy = impl Strategy<Value = ValidatedPathAndArgs>;
194194

195195
fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
196196
use proptest::prelude::*;
197197

198198
any::<(CanonicalizedComponentFunctionPath, ConvexArray)>().prop_map(|(path, args)| {
199-
ValidatedUdfPathAndArgs {
199+
ValidatedPathAndArgs {
200200
path,
201201
args,
202202
npm_version: None,
@@ -205,9 +205,9 @@ impl Arbitrary for ValidatedUdfPathAndArgs {
205205
}
206206
}
207207

208-
impl ValidatedUdfPathAndArgs {
208+
impl ValidatedPathAndArgs {
209209
/// Check if the function being called matches the allowed visibility and
210-
/// return a ValidatedUdfPath or an appropriate JsError.
210+
/// return a ValidatedPathAndARgs or an appropriate JsError.
211211
///
212212
/// We want to use the same error message for "this function exists, but
213213
/// with the wrong visibility" and "this function does not exist" so we
@@ -218,7 +218,7 @@ impl ValidatedUdfPathAndArgs {
218218
path: CanonicalizedComponentFunctionPath,
219219
args: ConvexArray,
220220
expected_udf_type: UdfType,
221-
) -> anyhow::Result<Result<ValidatedUdfPathAndArgs, JsError>> {
221+
) -> anyhow::Result<Result<ValidatedPathAndArgs, JsError>> {
222222
if path.udf_path.is_system() {
223223
anyhow::ensure!(
224224
path.component.is_root(),
@@ -228,7 +228,7 @@ impl ValidatedUdfPathAndArgs {
228228
// We don't analyze system modules, so we don't validate anything
229229
// except the identity for them.
230230
let result = if tx.identity().is_admin() || tx.identity().is_system() {
231-
Ok(ValidatedUdfPathAndArgs {
231+
Ok(ValidatedPathAndArgs {
232232
path,
233233
args,
234234
npm_version: None,
@@ -321,7 +321,7 @@ impl ValidatedUdfPathAndArgs {
321321
))));
322322
}
323323

324-
Ok(Ok(ValidatedUdfPathAndArgs {
324+
Ok(Ok(ValidatedPathAndArgs {
325325
path,
326326
args,
327327
npm_version: Some(udf_version),
@@ -386,15 +386,15 @@ impl ValidatedUdfPathAndArgs {
386386
}
387387
}
388388

389-
impl TryFrom<ValidatedUdfPathAndArgs> for pb::common::PathAndArgs {
389+
impl TryFrom<ValidatedPathAndArgs> for pb::common::PathAndArgs {
390390
type Error = anyhow::Error;
391391

392392
fn try_from(
393-
ValidatedUdfPathAndArgs {
393+
ValidatedPathAndArgs {
394394
path,
395395
args,
396396
npm_version,
397-
}: ValidatedUdfPathAndArgs,
397+
}: ValidatedPathAndArgs,
398398
) -> anyhow::Result<Self> {
399399
let args_json = JsonValue::from(args);
400400
let args = serde_json::to_vec(&args_json)?;
@@ -476,16 +476,16 @@ mod test {
476476

477477
use proptest::prelude::*;
478478

479-
use crate::ValidatedUdfPathAndArgs;
479+
use crate::ValidatedPathAndArgs;
480480
proptest! {
481481
#![proptest_config(
482482
ProptestConfig { failure_persistence: None, ..ProptestConfig::default() }
483483
)]
484484

485485
#[test]
486-
fn test_udf_path_proto_roundtrip(v in any::<ValidatedUdfPathAndArgs>()) {
486+
fn test_udf_path_proto_roundtrip(v in any::<ValidatedPathAndArgs>()) {
487487
let proto = pb::common::PathAndArgs::try_from(v.clone()).unwrap();
488-
let v2 = ValidatedUdfPathAndArgs::from_proto(proto).unwrap();
488+
let v2 = ValidatedPathAndArgs::from_proto(proto).unwrap();
489489
assert_eq!(v, v2);
490490
}
491491
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{
3838
JsonPackedValue,
3939
SyscallTrace,
4040
},
41-
ValidatedUdfPathAndArgs,
41+
ValidatedPathAndArgs,
4242
};
4343

4444
#[derive(Debug, Clone)]
@@ -207,7 +207,7 @@ impl UdfOutcome {
207207
result,
208208
syscall_trace,
209209
}: UdfOutcomeProto,
210-
path_and_args: ValidatedUdfPathAndArgs,
210+
path_and_args: ValidatedPathAndArgs,
211211
identity: InertIdentity,
212212
) -> anyhow::Result<Self> {
213213
let rng_seed = rng_seed.ok_or_else(|| anyhow::anyhow!("Missing rng_seed"))?;
@@ -257,7 +257,7 @@ mod tests {
257257
use super::{
258258
UdfOutcome,
259259
UdfOutcomeProto,
260-
ValidatedUdfPathAndArgs,
260+
ValidatedPathAndArgs,
261261
};
262262

263263
proptest! {
@@ -272,7 +272,7 @@ mod tests {
272272
let arguments = udf_outcome.arguments.clone();
273273
let version = udf_outcome.udf_server_version.clone();
274274
let identity = udf_outcome_clone.identity.clone();
275-
let path_and_args = ValidatedUdfPathAndArgs::new_for_tests(
275+
let path_and_args = ValidatedPathAndArgs::new_for_tests(
276276
udf_path,
277277
arguments,
278278
version

0 commit comments

Comments
 (0)