@@ -163,40 +163,47 @@ impl HTTPSubgraphExecutor {
163163 DurationOrExpression :: Expression ( expr) => {
164164 let value =
165165 VrlValue :: Object ( BTreeMap :: from ( [ ( "request" . into ( ) , client_request. into ( ) ) ] ) ) ;
166- let result = expr. execute ( value) . map_err ( |err| {
166+ let result = expr. execute_with_value ( value) . map_err ( |err| {
167167 SubgraphExecutorError :: TimeoutExpressionResolutionFailure ( err. to_string ( ) )
168168 } ) ?;
169169 match result {
170- VrlValue :: Integer ( i) if i >= 0 => std:: time:: Duration :: from_millis ( i as u64 ) ,
170+ VrlValue :: Integer ( i) => {
171+ if i < 0 {
172+ return Err ( SubgraphExecutorError :: TimeoutExpressionResolutionFailure (
173+ "Timeout expression resolved to a negative integer" . to_string ( ) ,
174+ ) ) ;
175+ }
176+ std:: time:: Duration :: from_millis ( i as u64 )
177+ }
171178 VrlValue :: Float ( f) => {
172179 let f = f. into_inner ( ) ;
173- if f >= 0.0 {
174- std:: time:: Duration :: from_millis ( f as u64 )
175- } else {
180+ if f < 0.0 {
176181 return Err ( SubgraphExecutorError :: TimeoutExpressionResolutionFailure (
177182 "Timeout expression resolved to a negative float" . to_string ( ) ,
178183 ) ) ;
179184 }
185+ std:: time:: Duration :: from_millis ( f as u64 )
180186 }
181187 VrlValue :: Bytes ( b) => {
182- let str : String = String :: from_utf8 ( b . to_vec ( ) ) . map_err ( |e| {
188+ let s = std :: str :: from_utf8 ( & b ) . map_err ( |e| {
183189 SubgraphExecutorError :: TimeoutExpressionResolutionFailure ( format ! (
184190 "Failed to parse duration string from bytes: {}" ,
185191 e
186192 ) )
187193 } ) ?;
188- let parsed = humantime:: parse_duration ( & str ) . map_err ( |e| {
194+ humantime:: parse_duration ( s ) . map_err ( |e| {
189195 SubgraphExecutorError :: TimeoutExpressionResolutionFailure ( format ! (
190196 "Failed to parse duration string '{}': {}" ,
191- str , e
197+ s , e
192198 ) )
193- } ) ?;
194- parsed
199+ } ) ?
195200 }
196- _ => {
201+ other => {
197202 return Err ( SubgraphExecutorError :: TimeoutExpressionResolutionFailure (
198- "Timeout expression did not resolve to a non-negative integer or float"
199- . to_string ( ) ,
203+ format ! (
204+ "Timeout expression resolved to an unexpected type: {}. Expected a non-negative integer/float (ms) or a duration string." ,
205+ other. kind( )
206+ ) ,
200207 ) ) ;
201208 }
202209 }
@@ -269,7 +276,7 @@ impl HTTPSubgraphExecutor {
269276
270277#[ async_trait]
271278impl SubgraphExecutor for HTTPSubgraphExecutor {
272- #[ tracing:: instrument( skip_all, fields( subgraph_name = self . subgraph_name) ) ]
279+ #[ tracing:: instrument( skip_all, fields( subgraph_name = % self . subgraph_name) ) ]
273280 async fn execute < ' exec , ' req > (
274281 & self ,
275282 execution_request : HttpExecutionRequest < ' exec , ' req > ,
0 commit comments