fix: Prevent callback validation ValueError from being suppressed

- Move signature parameter count validation outside try-except block
- Only catch exceptions from inspect.signature(), not validation errors
- Ensures invalid callbacks properly raise ValueError instead of passing silently
- Addresses final Cursor Bugbot issue with callback validation bypass

This resolves the remaining CI issue where the try-except block was too broad
and caught the ValueError that should propagate for invalid callback signatures.

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-09-29 11:13:40 +00:00
parent ed95f47b80
commit 1de7dcd3c2

View File

@@ -554,12 +554,13 @@ class Crew(FlowTrackable, BaseModel):
try:
sig = inspect.signature(self.task_ordering_callback)
except (ValueError, TypeError):
pass
else:
if len(sig.parameters) != 3:
raise ValueError(
"task_ordering_callback must accept exactly 3 parameters: (tasks, outputs, current_index)"
)
except (ValueError, TypeError):
pass
return self