@@ -1928,23 +1928,26 @@ impl<RT: Runtime> Application<RT> {
1928
1928
1929
1929
let mut tx = self . begin ( identity. clone ( ) ) . await ?;
1930
1930
1931
- // Use the last pushed version. If there hasn't been a push
1932
- // yet, act like the most recent version.
1933
- let server_version = UdfConfigModel :: new ( & mut tx, component. into ( ) )
1934
- . get ( )
1935
- . await ?
1936
- . map ( |udf_config| udf_config. server_version . clone ( ) )
1937
- . unwrap_or_else ( || Version :: parse ( "1000.0.0" ) . unwrap ( ) ) ;
1931
+ let mut udf_config_model = UdfConfigModel :: new ( & mut tx, component. into ( ) ) ;
1932
+ let udf_config = match udf_config_model. get ( ) . await ? {
1933
+ Some ( udf_config) => udf_config. into_value ( ) ,
1934
+ None => {
1935
+ // If there hasn't been a push
1936
+ // yet, act like the most recent version.
1937
+ let udf_config = UdfConfig {
1938
+ server_version : Version :: new ( 1000 , 0 , 0 ) ,
1939
+ import_phase_rng_seed : self . runtime . with_rng ( |rng| rng. gen ( ) ) ,
1940
+ import_phase_unix_timestamp : self . runtime . unix_timestamp ( ) ,
1941
+ } ;
1942
+ udf_config_model. set ( udf_config. clone ( ) ) . await ?;
1943
+ udf_config
1944
+ } ,
1945
+ } ;
1938
1946
1939
1947
// 1. analyze the module
1940
1948
// We can analyze this module by itself, without combining it with the existing
1941
1949
// modules since this module should be self-contained and not import
1942
1950
// from other modules.
1943
- let udf_config = UdfConfig {
1944
- server_version,
1945
- import_phase_rng_seed : self . runtime . with_rng ( |rng| rng. gen ( ) ) ,
1946
- import_phase_unix_timestamp : self . runtime . unix_timestamp ( ) ,
1947
- } ;
1948
1951
1949
1952
let analyze_results = self
1950
1953
. analyze (
@@ -1973,10 +1976,16 @@ impl<RT: Runtime> Application<RT> {
1973
1976
if function. name . is_default_export ( ) {
1974
1977
analyzed_function = Some ( function. clone ( ) ) ;
1975
1978
} else {
1976
- anyhow:: bail!( "Only `export default` is supported." ) ;
1979
+ anyhow:: bail!( ErrorMetadata :: bad_request(
1980
+ "InvalidTestQuery" ,
1981
+ "Only `export default` is supported."
1982
+ ) ) ;
1977
1983
}
1978
1984
}
1979
- let analyzed_function = analyzed_function. context ( "Missing default export." ) ?;
1985
+ let analyzed_function = analyzed_function. context ( ErrorMetadata :: bad_request (
1986
+ "InvalidTestQuery" ,
1987
+ "Default export is not a Convex function." ,
1988
+ ) ) ?;
1980
1989
1981
1990
let source_package_id = SourcePackageModel :: new ( & mut tx, component. into ( ) )
1982
1991
. put ( source_package)
@@ -2015,16 +2024,22 @@ impl<RT: Runtime> Application<RT> {
2015
2024
} | { ( result, log_lines) } ,
2016
2025
) ,
2017
2026
UdfType :: Mutation => {
2018
- anyhow:: bail!( "Mutations are not supported in the REPL yet." )
2027
+ anyhow:: bail!( ErrorMetadata :: bad_request(
2028
+ "UnsupportedTestQuery" ,
2029
+ "Mutations are not supported in the REPL yet."
2030
+ ) )
2019
2031
} ,
2020
2032
UdfType :: Action => {
2021
- anyhow:: bail!( "Actions are not supported in the REPL yet." )
2033
+ anyhow:: bail!( ErrorMetadata :: bad_request(
2034
+ "UnsupportedTestQuery" ,
2035
+ "Actions are not supported in the REPL yet."
2036
+ ) )
2022
2037
} ,
2023
2038
UdfType :: HttpAction => {
2024
- anyhow:: bail!(
2025
- "HTTP actions are not supported in the REPL. A \" not found \" message should \
2026
- be returned instead ."
2027
- )
2039
+ anyhow:: bail!( ErrorMetadata :: bad_request (
2040
+ "UnsupportedTestQuery" ,
2041
+ "HTTP actions are not supported in the REPL yet ."
2042
+ ) )
2028
2043
} ,
2029
2044
} ?;
2030
2045
let log_lines = RedactedLogLines :: from_log_lines ( log_lines, block_logging) ;
0 commit comments