mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-23 16:10:27 +08:00
fix(lfx): restore synchronous AllTypesDict.get_type_dict
cz/hitl-v2 regressed the release-1.11.0 fix: get_type_dict called the async get_all_types_dict synchronously, so the sync _build_dict received an un-awaited coroutine and the first Graph.from_payload raised "'coroutine' object is not a mapping" — breaking json_schema_from_flow and MCP tool-schema generation. Restore the sync build_custom_components path (identical to release-1.11.0) and its regression test.
This commit is contained in:
@ -17,10 +17,14 @@ class AllTypesDict(LazyLoadDictBase):
|
||||
|
||||
@override
|
||||
def get_type_dict(self):
|
||||
from lfx.custom.utils import get_all_types_dict
|
||||
# Must stay synchronous: this is reached from the sync `all_types_dict` property during
|
||||
# graph build (vertex base_type fallback). Use the sync builder, not the async
|
||||
# `get_all_types_dict` (returning its un-awaited coroutine raised
|
||||
# "'coroutine' object is not a mapping").
|
||||
from lfx.custom.utils import build_custom_components
|
||||
|
||||
settings_service = get_settings_service()
|
||||
return get_all_types_dict(settings_service.settings.components_path)
|
||||
return build_custom_components(settings_service.settings.components_path)
|
||||
|
||||
|
||||
lazy_load_dict = AllTypesDict()
|
||||
|
||||
20
src/lfx/tests/unit/interface/test_listing.py
Normal file
20
src/lfx/tests/unit/interface/test_listing.py
Normal file
@ -0,0 +1,20 @@
|
||||
"""Tests for lfx.interface.listing — the synchronous all-types lookup."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_all_types_dict_is_a_mapping_not_a_coroutine():
|
||||
"""`all_types_dict` must return a real mapping synchronously.
|
||||
|
||||
Regression: `get_type_dict` called the async `get_all_types_dict` without awaiting it,
|
||||
so the sync `_build_dict` did `{**coroutine}` and raised
|
||||
"'coroutine' object is not a mapping". This path is reached during graph build (a vertex
|
||||
falling back to look up its base_type), so every flow that hit it failed to load.
|
||||
"""
|
||||
from lfx.interface.listing import AllTypesDict
|
||||
|
||||
result = AllTypesDict().all_types_dict
|
||||
|
||||
assert isinstance(result, dict)
|
||||
# The sync builder discovers the bundled component categories plus the "Custom" entry.
|
||||
assert "Custom" in result
|
||||
Reference in New Issue
Block a user