diff --git a/src/backend/base/langflow/initial_setup/setup.py b/src/backend/base/langflow/initial_setup/setup.py index 1d91ea3c5b..329360291b 100644 --- a/src/backend/base/langflow/initial_setup/setup.py +++ b/src/backend/base/langflow/initial_setup/setup.py @@ -62,10 +62,11 @@ from langflow.services.deps import ( def update_projects_components_with_latest_component_versions(project_data, all_types_dict): # Flatten the all_types_dict for easy access - all_types_dict_flat = {} - for category in all_types_dict.values(): - for key, component in category.items(): - all_types_dict_flat[key] = component + all_types_dict_flat = { + key: component + for category in all_types_dict.values() + for key, component in category.items() + } node_changes_log = defaultdict(list) project_data_copy = deepcopy(project_data) diff --git a/src/lfx/src/lfx/services/settings/base.py b/src/lfx/src/lfx/services/settings/base.py index 7f7074e81a..534e3f0995 100644 --- a/src/lfx/src/lfx/services/settings/base.py +++ b/src/lfx/src/lfx/services/settings/base.py @@ -509,6 +509,26 @@ class Settings(BaseSettings): return str(value) + @field_validator("cache_dir", mode="before") + @classmethod + def validate_cache_dir(cls, value): + """Validate and normalize cache_dir path. + + If not set, returns None and the factory will fall back to config_dir. + If set, resolves to an absolute path and creates the directory if needed. + """ + if not value: + return None + + if isinstance(value, str): + value = Path(value) + # Resolve to absolute path to handle relative paths correctly + value = value.resolve() + if not value.exists(): + value.mkdir(parents=True, exist_ok=True) + + return str(value) + @field_validator("database_url", mode="before") @classmethod def set_database_url(cls, value, info):