Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: drop redundant len(tag_ids)==0 check in get_target_ids_by_tag_ids (#38447)

i晟586c8de1a08b
diff --git a/api/core/app/app_config/common/sensitive_word_avoidance/manager.py b/api/core/app/app_config/common/sensitive_word_avoidance/manager.py
index b02b4077338..314848d168d 100644
--- a/api/core/app/app_config/common/sensitive_word_avoidance/manager.py
+++ b/api/core/app/app_config/common/sensitive_word_avoidance/manager.py
@@ -61,10 +61,17 @@ _sensitive_word_avoidance_adapter: TypeAdapter[SensitiveWordAvoidanceConfig] = T
def _normalize_raw(raw: Any) -> Any:
if isinstance(raw, dict):
- if raw.get("enabled") is None:
+ enabled = raw.get("enabled")
+ if enabled is None:
raw = {**raw, "enabled": False}
- elif raw.get("enabled") is True and raw.get("config") is None:
- raw = {**raw, "config": {}}
+ elif enabled is True:
+ if raw.get("config") is None:
+ raw = {**raw, "config": {}}
+ else:
+ # enabled is False or any falsy value —
+ # drop extra fields (type, config) so they don't
+ # violate SensitiveWordAvoidanceDisabledConfig.extra="forbid"
+ raw = {"enabled": False}
return raw
diff --git a/api/services/tag_service.py b/api/services/tag_service.py
index 1827720dfc9..2d89bafa920 100644
--- a/api/services/tag_service.py
+++ b/api/services/tag_service.py
@@ -73,7 +73,7 @@ class TagService:
target must be bound to all requested tags.
"""
# Check if tag_ids is not empty to avoid WHERE false condition
- if not tag_ids or len(tag_ids) == 0:
+ if not tag_ids:
return []
# Deduplicate repeated query params so match_all counts each requested tag once.
requested_tag_ids = list(dict.fromkeys(tag_ids))
@@ -88,7 +88,7 @@ class TagService:
return []
tag_ids = list(tags)
# Check if tag_ids is not empty to avoid WHERE false condition
- if not tag_ids or len(tag_ids) == 0:
+ if not tag_ids:
return []
if match_all:
if len(tag_ids) != len(requested_tag_ids):