From 1de7dcd3c299baad9f62e87cd61d6b830aa52616 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 11:13:40 +0000 Subject: [PATCH] fix: Prevent callback validation ValueError from being suppressed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/crewai/crew.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crewai/crew.py b/src/crewai/crew.py index 64998329d..7664349ef 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -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