Skip to content

Commit 12b3f4f

Browse files
committed
Refactor error handling and simplify execution ID extraction in TemporalEventListener
1 parent 5a0d560 commit 12b3f4f

File tree

2 files changed

+15
-38
lines changed

2 files changed

+15
-38
lines changed

orchestrator/core/src/application/tool_invocation_service.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ impl ToolInvocationService {
143143
.tool_router
144144
.route_tool(session.execution_id, &tool_name)
145145
.await
146-
.map_err(|e| {
147-
SmcpSessionError::MalformedPayload(format!("Routing error: {}", e))
148-
})?;
146+
.map_err(|e| SmcpSessionError::MalformedPayload(format!("Routing error: {}", e)))?;
149147

150148
let server = self.tool_router.get_server(server_id).await.ok_or(
151149
SmcpSessionError::MalformedPayload("Server vanished after routing".to_string()),
@@ -335,13 +333,10 @@ impl ToolInvocationService {
335333

336334
loop {
337335
if attempts >= max_attempts {
338-
return Err(SmcpSessionError::JudgeTimeout(
339-
format!(
340-
"Inner-loop semantic judge '{}' timed out after {} seconds.",
341-
judge_agent,
342-
timeout_seconds
343-
),
344-
));
336+
return Err(SmcpSessionError::JudgeTimeout(format!(
337+
"Inner-loop semantic judge '{}' timed out after {} seconds.",
338+
judge_agent, timeout_seconds
339+
)));
345340
}
346341

347342
let exec = self
@@ -1004,11 +999,7 @@ fn sanitize_segment(input: &str) -> String {
1004999

10051000
// Prevent path traversal patterns after character substitution.
10061001
// Treat empty or traversal-like segments as a safe default.
1007-
if sanitized.is_empty()
1008-
|| sanitized == "."
1009-
|| sanitized == ".."
1010-
|| sanitized.contains("..")
1011-
{
1002+
if sanitized.is_empty() || sanitized == "." || sanitized == ".." || sanitized.contains("..") {
10121003
"unversioned".to_string()
10131004
} else {
10141005
sanitized

orchestrator/core/src/infrastructure/temporal_event_listener.rs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -370,29 +370,15 @@ impl TemporalEventListener {
370370
self.event_bus.publish_workflow_event(domain_event.clone());
371371
return Ok(String::new());
372372
}
373-
WorkflowEvent::WorkflowExecutionStarted { execution_id, .. } => {
374-
execution_id.clone()
375-
}
376-
WorkflowEvent::WorkflowStateEntered { execution_id, .. } => execution_id.clone(),
377-
WorkflowEvent::WorkflowStateExited { execution_id, .. } => execution_id.clone(),
378-
WorkflowEvent::WorkflowIterationStarted { execution_id, .. } => {
379-
execution_id.clone()
380-
}
381-
WorkflowEvent::WorkflowIterationCompleted { execution_id, .. } => {
382-
execution_id.clone()
383-
}
384-
WorkflowEvent::WorkflowIterationFailed { execution_id, .. } => {
385-
execution_id.clone()
386-
}
387-
WorkflowEvent::WorkflowExecutionCompleted { execution_id, .. } => {
388-
execution_id.clone()
389-
}
390-
WorkflowEvent::WorkflowExecutionFailed { execution_id, .. } => {
391-
execution_id.clone()
392-
}
393-
WorkflowEvent::WorkflowExecutionCancelled { execution_id, .. } => {
394-
execution_id.clone()
395-
}
373+
WorkflowEvent::WorkflowExecutionStarted { execution_id, .. } => *execution_id,
374+
WorkflowEvent::WorkflowStateEntered { execution_id, .. } => *execution_id,
375+
WorkflowEvent::WorkflowStateExited { execution_id, .. } => *execution_id,
376+
WorkflowEvent::WorkflowIterationStarted { execution_id, .. } => *execution_id,
377+
WorkflowEvent::WorkflowIterationCompleted { execution_id, .. } => *execution_id,
378+
WorkflowEvent::WorkflowIterationFailed { execution_id, .. } => *execution_id,
379+
WorkflowEvent::WorkflowExecutionCompleted { execution_id, .. } => *execution_id,
380+
WorkflowEvent::WorkflowExecutionFailed { execution_id, .. } => *execution_id,
381+
WorkflowEvent::WorkflowExecutionCancelled { execution_id, .. } => *execution_id,
396382
};
397383

398384
let execution_id_str = execution_id_obj.0.to_string();

0 commit comments

Comments
 (0)