You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address PR review: improve handler validation guards and guidance consistency
- Gate return-check on has_handler_function && no signature issue to
avoid misleading 'MUST return' errors on invalid handler shapes
- Expand check_handler_has_return skip logic to also skip arrow function
bodies (=> { ... }) and generator declarations (function*)
- Fix conflicting guidance in register_handler tool description: use
function handler(...) instead of function handler(event) in REQUIRED line
- Add zero-parameter form function handler() to system-message signature list
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
// Check for return statement inside handler (uses comment-stripped source)
577
-
let has_return = check_handler_has_return(&clean);
578
-
if !has_return {
579
-
errors.push(ValidationError{
580
-
error_type:"structure".to_string(),
581
-
message:"Handler function MUST return a value. Without 'return' you will get: 'The handler function did not return a value'. Fix: add 'return { ... };' at the end of your handler function.".to_string(),
582
-
line:None,
583
-
column:None,
584
-
});
577
+
// Only check for return when handler is a real function declaration and
578
+
// has no signature issues — invalid shapes (arrow handlers, etc.) can
579
+
// cause misleading "MUST return" errors.
580
+
if !has_signature_issue && has_handler_function {
581
+
let has_return = check_handler_has_return(&clean);
582
+
if !has_return {
583
+
errors.push(ValidationError{
584
+
error_type:"structure".to_string(),
585
+
message:"Handler function MUST return a value. Without 'return' you will get: 'The handler function did not return a value'. Fix: add 'return { ... };' at the end of your handler function.".to_string(),
0 commit comments