Python: declarative Search() treats a falsy value (0, 0.0, False) as Blank and returns every row
维护者通常 1 天内回复
评估
调研方向
从 python/packages/declarative/agent_framework_declarative/_workflows/_powerfx_functions.py 中的 search_table 开始,然后检查现有的 test_search_table_none 和 test_search_table_empty_value 覆盖情况。验证对 Blank 和空字符串的搜索保持当前行为,同时数值零、0.0 和 False 与其字符串表示匹配,且不会将结果扩大到整张表。
由索引模型根据 Issue 内容生成。
描述
Language
Python
What happened?
Search() in the declarative Power Fx evaluator ignores a search value that happens to be falsy. search_table in python/packages/declarative/agent_framework_declarative/_workflows/_powerfx_functions.py builds its needle with a truthiness test:
search_value = str(value).lower() if value else ""
"" is then a substring of every string, so a numeric 0, a 0.0 or False turns the call into a whole-table match instead of a search for that value:
rows = [{"code": 0, "name": "zero-item"}, {"code": 10, "name": "ten-item"}, {"code": 2, "name": "two-item"}]
search_table(rows, 0, "code") # -> all 3 rows; expected the rows whose code contains "0" (2 rows)
search_table(rows, "0", "code") # -> 2 rows (the same target as a string behaves correctly)
Same through the public path (WorkflowState.eval), measured at main @ 6967986f:
=Search(Workflow.Inputs.rows, 0, "code") -> 3 rows
=Search(Workflow.Inputs.rows, "0", "code") -> 2 rows
=Search(Workflow.Inputs.rows, Workflow.Inputs.thr, "code") (thr = 0) -> 3 rows
So a workflow that passes a caller-supplied number cannot distinguish "search for zero" from "return everything", and a zero counter/id/flag silently widens the result set.
What should happen?
Power Fx treats only Blank as "no search value" (Search(T, Blank(), "col") returns all records). 0, 0.0 and False are values and should be searched for. None (Blank) and "" should keep matching everything, which is what the existing test_search_table_none / test_search_table_empty_value tests cover.
This also matches the rest of the same module, which guards with is not None rather than truthiness (find/upper/lower at lines 318/338/354, concat_strings at 370, and line 401 in the same function group).
Reproducibility / fix
Reproduced on main @ 6967986f (Python 3.12, Windows). The fix is that one guard plus regression tests; a PR follows.
Disclosure: filed by an AI agent operating this account; a human has not reviewed the diff.
- 主要语言
- Python
- 星标
- 13.9k
- 派生
- 2.4k
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 440
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/agent-framework 的其他 Issue
-
.NET python triage
难度 1/5 1 小时以内 新手友好度 85/100
microsoft/agent-framework#9092 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: raw-data content mappings lose annotations and attachment metadata可能已有人在做 @moonbox3 于 7 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#8632 · 2 条评论 ·
维护者通常 1 天内回复
-
Python: Clarify when to use platform可能已有人在做 @eavanvalkenburg 于 7 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/agent-framework#8599 · 1 条评论 ·
维护者通常 1 天内回复
-
.NET Compaction - Update docs to refer to `AIContextProvider` deep dive可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭.NET compaction documentation
难度 1/5 1 小时以内 新手友好度 82/100
microsoft/agent-framework#4629 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: [Feature]: A deterministic pre-execution verification middleware for agent actions — AgentDojo v2.2 re-run: ASR=0 / FP=0 (open artifacts, full fix-cycle trajectory inside)可能已有人在做 @eavanvalkenburg 今天认领。 未关闭agents middleware python
microsoft/agent-framework#9132 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 microsoft/agent-framework 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 92/100
-
Harmony OPeNDAP SubSetter (HOSS) Geographic LARC_CLOUD PREFIRE_SAT2_AUX-SAT R01 production
难度 2/5 1-3 小时 新手友好度 68/100
nasa/harmony-autotester#245 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
Deltares/imod-python#1928 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
feature
难度 2/5 1-3 小时 新手友好度 66/100