From 2eb786cdd94eea6761c9f95ad59fc259118ccddd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 2 Jul 2024 18:21:57 -0300 Subject: [PATCH] feat(utils.py): add error handling for missing template_config in build_custom_component_template (#2491) --- src/backend/base/langflow/custom/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/backend/base/langflow/custom/utils.py b/src/backend/base/langflow/custom/utils.py index 4dd96f1c2..0b2da65f8 100644 --- a/src/backend/base/langflow/custom/utils.py +++ b/src/backend/base/langflow/custom/utils.py @@ -388,6 +388,17 @@ def build_custom_component_template( ) -> Tuple[Dict[str, Any], CustomComponent | Component]: """Build a custom component template""" try: + if not hasattr(custom_component, "template_config"): + raise HTTPException( + status_code=400, + detail={ + "error": ( + "Please check if you are importing Component correctly." + " It should be `from langflow.custom import Component`" + ), + "traceback": traceback.format_exc(), + }, + ) if "inputs" in custom_component.template_config: return build_custom_component_template_from_inputs(custom_component, user_id=user_id) frontend_node = CustomComponentFrontendNode(**custom_component.template_config)