You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: correct MSJ call site and harden litellm rate-limit detection
Two related fixes uncovered during an audit of the msj_data fix (0944ac6),
plus a pre-commit formatting/lint fix:
1. perform_many_shot_scan passed wrong type to msj_data.prepare_prompts
- File: agentic_security/probe_actor/fuzzer.py
- Bug: probe_datasets (list[dict], e.g. {"dataset_name": ..., "selected": ...})
was forwarded directly, but msj_data.prepare_prompts expects list[str].
- Effect: After 0944ac6 made prepare_prompts honor its dataset_names param,
every MSJ multi-step scan silently loaded an empty dataset (the lookup
`name in dataset_map` is always False when name is a dict).
- Fix: extract the dataset_name strings and drop unselected entries,
matching the existing data.prepare_prompts call a few lines above.
- Test: add test_many_shot_passes_dataset_names_to_msj, which fails on the
buggy code (asserts the mock receives ['probe-a'], not the raw dict list).
2. litellm rate-limit detection switched from string compare to isinstance
- File: agentic_security/llm_providers/litellm_provider.py
- Bug: _handle_error detected rate limits by comparing
type(e).__module__ + __name__ to 'litellm.exceptions.RateLimitError'.
Fragile (breaks on subclassing/module renames) and inconsistent with
openai_provider.py and anthropic_provider.py, which both use isinstance.
- Fix: use isinstance(e, litellm.exceptions.RateLimitError), guarded by
`litellm is not None` since litellm is an optional import.
- Test: replace the fabricated fake exception (monkeypatched __module__) with
a real subclass of litellm.exceptions.RateLimitError so the isinstance
path is genuinely exercised.
3. Pre-commit lint fixes (unblock CI on this branch)
- Apply black formatting to fuzzer.py and test_fuzzer.py.
- agentic_security/probe_data/image_generator.py: add `# noqa: E402` to the
two imports (cache_to_disk, tqdm) that run after `matplotlib.use("Agg")`,
matching the existing noqa on the line above. This E402 also exists on
main and was surfaced because the CI runs `pre-commit run --all-files`.
0 commit comments