mirror of
https://github.com/langgenius/dify.git
synced 2026-07-20 19:50:06 -04:00
refactor: drop redundant len(tag_ids)==0 check in get_target_ids_by_tag_ids (#38447)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user