Metadata filters crash on keys containing dots or other special characters
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 25/100
调研方向
The bug is in the metadata condition builders in pyrit/memory/sqlite_memory.py and pyrit/memory/azure_sql_memory.py, specifically _get_seed_metadata_conditions and _get_message_pieces_prompt_metadata_conditions, where the key is interpolated into the JSON path and the bind name. Read the label fix from #3063 for the pattern. PR #3180 is already open against this, so check it before starting. Done means a dotted key like a.b filters correctly in both backends.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Filtering seeds or message pieces by a prompt_metadata key that contains a dot (or any character outside a plain SQL bind name, like a hyphen or a space) crashes the query instead of filtering.
In sqlite_memory.py and azure_sql_memory.py, _get_seed_metadata_conditions and _get_message_pieces_prompt_metadata_conditions build the SQL with the key interpolated into both the JSON path and the bind parameter name:
f"JSON_EXTRACT(prompt_metadata, '$.{key}') = :{key}"
For a key like a.b, SQLAlchemy parses :a.b as a parameter named a followed by literal text, so the later bindparams() call raises ArgumentError: This text() construct doesn't define a bound parameter named 'a.b'.
This is the same class of problem #3063 fixed for memory labels, where the accepted fix quotes the JSON path and uses indexed parameter names.
Steps/Code to Reproduce
import asyncio, tempfile
from pyrit.memory.sqlite_memory import SQLiteMemory
from pyrit.models import SeedPrompt
async def main():
memory = SQLiteMemory(db_path=tempfile.mktemp(suffix=".db"), verbose=False)
await memory.add_seeds_to_memory_async(seeds=[
SeedPrompt(value="dotted", data_type="text", dataset_name="t", metadata={"a.b": "v1"}),
], added_by="repro")
got = await memory.get_seeds_async(metadata={"a.b": "v1"}) # raises ArgumentError
print(got)
asyncio.run(main())
Expected Results
The filter matches the stored seed by the literal metadata key a.b and returns it.
Actual Results
sqlalchemy.exc.ArgumentError: This text() construct doesn't define a bound parameter named 'a.b'
Screenshots
N/A
Versions
OS: macOS
Python version: 3.14
PyRIT version: installed from main (66c41fa)
- 主要语言
- Python
- 星标
- 4.6k
- 派生
- 944
- 平均合并
- 2 天 18 小时
- 30 天内合并 PR
- 358
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/PyRIT 的其他 Issue
-
BUG: label queries only return the final conversation of an attack可能已有人在做 @u7k4rs6 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/PyRIT#3095 · 4 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
BUG Configuration keeps runtime-status errors after polling recovers可能已有人在做 @joeyvictorino 于 5 天前认领。 未关闭Bug: triage GUI help wanted
难度 2/5 1-3 小时 新手友好度 86/100
microsoft/PyRIT#2868 · 6 条评论 ·
维护者通常 2 天内回复
-
Crescendo backtracking keeps the refused prompt when the objective target made a tool call可能已有人在做 @RachelWanggg 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 30/100
维护者通常 2 天内回复
-
BUG BinAsciiConverter UUencode output cannot be decoded when all words are converted可能已有人在做 @barkha1research-ai 今天认领。 未关闭Bug: triage
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 2 天内回复
-
FEAT Proposal: red-team decision models as targets (decision flip-rate testing)可能已有人在做 @shashank03-dev 今天认领。 未关闭
难度 5/5 一周以上 新手友好度 15/100
microsoft/PyRIT#3246 · 2 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
huggingface/sentence-transformers#4186 ·
维护者通常 5 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 92/100
QuantEcon/QuantEcon.py#988 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
fabriziosalmi/certmate#1247 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 半天 新手友好度 72/100
sujithputta02/Esapay#13 ·