refactor: drop redundant len(tag_ids)==0 check in get_target_ids_by_tag_ids#38447
Merged
asukaminato0721 merged 2 commits intoJul 6, 2026
Merged
Conversation
When a client sends sensitive_word_avoidance with enabled=false but
also includes type/config fields, _normalize_raw() passes them through
unchanged. This causes pydantic ValidationError because
SensitiveWordAvoidanceDisabledConfig has extra='forbid', resulting in
HTTP 400 invalid_param.
Add an else branch to strip extra fields when enabled is not True,
keeping only {'enabled': False}.
Fixes langgenius#38409
…ag_ids Both branches of get_target_ids_by_tag_ids() use: if not tag_ids or len(tag_ids) == 0: The second disjunct is subsumed by 'not tag_ids' — any sequence where len(x)==0 also satisfies 'not x'. Collapse to just 'if not tag_ids:' for clarity. No behavior change. Fixes langgenius#38405
Contributor
Pyrefly Type Coverage
|
asukaminato0721
approved these changes
Jul 6, 2026
Contributor
Author
|
感谢 @asukaminato0721 快速 review 和合入! 简单介绍一下自己——我是太原理工大学(211)软件工程大二学生,专注 AI Agent 开发。之前做过几个相关项目:
提交的 6 个 PR 让我对 Dify 的代码库越来越熟悉,尤其是 Agent 和 RAG 相关模块。想问问团队是否招实习生?我暑期可立即到岗。邮箱 ishengeqi@163.com,GitHub: isheng-eqi。期待有机会更深入参与! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #38405
Problem
Both branches of
get_target_ids_by_tag_ids()inapi/services/tag_service.pyuse:The
len(tag_ids) == 0disjunct is fully redundant — any sequence wherelen(x) == 0also satisfiesnot x. This is a holdover from the recent TagService refactor (#38313) which switched the signature to an explicit session argument but didn't collapse the guard.Fix
Collapse both guards to
if not tag_ids:.Changes
api/services/tag_service.py: Removeor len(tag_ids) == 0from lines 76 and 91No behavior change. No public API change.