Skip to content

Commit 167796b

Browse files
authored
fix(generic): prevent infinite recursion in generic component fallback (#762)
- Adds an explicit check to ensure that the generic component does not attempt to call itself recursively when resolving by mimetype. Now only calls a component function if the resolved component_type is both truthy and not 'generic'.
1 parent 4e6e599 commit 167796b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

preswald/interfaces/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def generic(content, mimetype: str, component_id: str | None = None, **kwargs) -
280280

281281
component_type = get_component_type_for_mimetype(mimetype)
282282

283-
if component_type:
283+
if component_type and component_type != 'generic':
284284
component_fn = getattr(interfaces.components, component_type, None)
285285
if callable(component_fn):
286286
return component_fn(content, component_id=component_id, mimetype=mimetype, **kwargs)

0 commit comments

Comments
 (0)