fix: avoid checking variables with empty value (#5367)
fix: enhance load_from_db field checks in custom component update and parameter loading - Updated the condition in to ensure that only includes fields with a defined value. - Modified the function to skip parameters that are either not present or have a falsy value, improving robustness in parameter handling.
This commit is contained in:
parent
22877ae920
commit
b7f5a7fe9b
2 changed files with 2 additions and 2 deletions
|
|
@ -622,7 +622,7 @@ async def custom_component_update(
|
||||||
load_from_db_fields = [
|
load_from_db_fields = [
|
||||||
field_name
|
field_name
|
||||||
for field_name, field_dict in template.items()
|
for field_name, field_dict in template.items()
|
||||||
if isinstance(field_dict, dict) and field_dict.get("load_from_db")
|
if isinstance(field_dict, dict) and field_dict.get("load_from_db") and field_dict.get("value")
|
||||||
]
|
]
|
||||||
params = await update_params_with_load_from_db_fields(cc_instance, params, load_from_db_fields)
|
params = await update_params_with_load_from_db_fields(cc_instance, params, load_from_db_fields)
|
||||||
cc_instance.set_attributes(params)
|
cc_instance.set_attributes(params)
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ async def update_params_with_load_from_db_fields(
|
||||||
fallback_to_env_vars=False,
|
fallback_to_env_vars=False,
|
||||||
):
|
):
|
||||||
for field in load_from_db_fields:
|
for field in load_from_db_fields:
|
||||||
if field not in params:
|
if field not in params or not params[field]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue