Metadata filters crash on keys containing dots or other special characters
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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日 16時間
- マージ済み PR(30日)
- 350
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/PyRIT のほかの issue
-
BUG: label queries only return the final conversation of an attack対応中かも @u7k4rs6 が 1 日前に担当しました。 オープン
難易度 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 1週間以上 初心者へのやさしさ 15/100
microsoft/PyRIT#3246 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
microsoft/PyRIT の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jbacalso24/mimry#291 ·
メンテナーはふだん 1 日以内に返信
-
good first issue
難易度 2/5 1時間未満 初心者へのやさしさ 82/100
eli-alvarado/us-watchlist-alerts#14 ·
メンテナーはふだん 1 日以内に返信
-
from-review-extraction python severity:nit
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
LearningCircuit/local-deep-research#7462 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cathrynlavery/diagram-design#441 ·
メンテナーはふだん 2 日以内に返信
-
[Cleanup] Include the public header in work_split.cpp対応中かも @blozano-tt が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tenstorrent/tt-metal#60850 ·
メンテナーはふだん 1 日以内に返信