{"record":{"id":"23eba2897be24e20","repo":"huggingface/smolagents","slug":"this-is-not-a-correct-function-call-func","errorCode":null,"errorMessage":"This is not a correct function: {call.func}).","messagePattern":"This is not a correct function: (.+?)\\)\\.","errorType":"error_code","errorClass":"InterpreterError","httpStatus":null,"severity":"warning","filePath":"src/smolagents/local_python_executor.py","lineNumber":833,"sourceCode":"            set_value(elem, value[i], state, static_tools, custom_tools, authorized_imports)\n    elif isinstance(target, ast.Subscript):\n        obj = evaluate_ast(target.value, state, static_tools, custom_tools, authorized_imports)\n        key = evaluate_ast(target.slice, state, static_tools, custom_tools, authorized_imports)\n        obj[key] = value\n    elif isinstance(target, ast.Attribute):\n        obj = evaluate_ast(target.value, state, static_tools, custom_tools, authorized_imports)\n        setattr(obj, target.attr, value)\n\n\ndef evaluate_call(\n    call: ast.Call,\n    state: dict[str, Any],\n    static_tools: dict[str, Callable],\n    custom_tools: dict[str, Callable],\n    authorized_imports: list[str],\n) -> Any:\n    if not isinstance(call.func, (ast.Call, ast.Lambda, ast.Attribute, ast.Name, ast.Subscript)):\n        raise InterpreterError(f\"This is not a correct function: {call.func}).\")\n\n    func, func_name = None, None\n\n    if isinstance(call.func, ast.Call):\n        func = evaluate_ast(call.func, state, static_tools, custom_tools, authorized_imports)\n    elif isinstance(call.func, ast.Lambda):\n        func = evaluate_ast(call.func, state, static_tools, custom_tools, authorized_imports)\n    elif isinstance(call.func, ast.Attribute):\n        obj = evaluate_ast(call.func.value, state, static_tools, custom_tools, authorized_imports)\n        func_name = call.func.attr\n        if not hasattr(obj, func_name):\n            raise InterpreterError(f\"Object {obj} has no attribute {func_name}\")\n        func = getattr(obj, func_name)\n    elif isinstance(call.func, ast.Name):\n        func_name = call.func.id\n        if func_name in state:\n            func = state[func_name]\n        elif func_name in static_tools:","sourceCodeStart":815,"sourceCodeEnd":851,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L815-L851","documentation":"evaluate_call only accepts callables reached via ast.Call, ast.Lambda, ast.Attribute, ast.Name, or ast.Subscript expressions; any other func node shape raises InterpreterError. It is a defensive structural check on the AST, not a runtime type error (the paren and period in the message are cosmetic).","triggerScenarios":"Practically unreachable from normal Python source since the grammar only produces those node types for callees; fires only with hand-constructed/mutated ASTs (e.g. calling evaluate_ast directly with an exotic call.func node).","commonSituations":"Programmatic AST generation feeding the executor; AST transformers/optimizers that replace the callee with an unexpected node type.","solutions":["Ensure executed code uses standard call syntax (name, attribute, subscript, call or lambda as the callee)","If generating ASTs, keep call.func within the five supported node types","Execute source strings via evaluate_python/evaluate_script rather than custom ASTs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import ast\nfor node in ast.walk(ast.parse(code)):\n    if isinstance(node, ast.Call) and not isinstance(node.func, (ast.Call, ast.Lambda, ast.Attribute, ast.Name, ast.Subscript)):\n        raise ValueError('unsupported call target in AST')","typeGuard":null,"tryCatchPattern":"from smolagents.local_python_executor import InterpreterError\ntry:\n    evaluate_python(code)\nexcept InterpreterError as e:\n    if 'not a correct function' in str(e):\n        raise SyntaxRestriction(str(e)) from e","preventionTips":["Execute plain source strings rather than custom ASTs","Keep callee expressions in standard forms (name, attribute, subscript, call, lambda)","Validate generated ASTs before handing them to the executor"],"tags":["smolagents","function-call","ast-validation","interpreter-error","unsupported-operation"],"backgroundTag":"unsupported-language-construct","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}