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
{{ message }}
Repository navigation
BUG: Disabled debug logs stringify default values and can break registration #3903
Two DEBUG log statements in pyrit/common/apply_defaults.py:121,355 eagerly stringify arbitrary default values even when DEBUG is disabled. A value with a raising __str__ causes registration to raise after storing the value, and prevents a decorated constructor from being entered. Passing the same value explicitly works.
This is a focused runtime fix and regression request, not blanket adoption of Ruff G rules. #3721 is open but already has open implementation PR #3843 for RUF/F changes; that work does not cover these default-value logging sites.
Use an isolated process: the example resets global default-value registrations during cleanup.
Expected Results
Disabled DEBUG must not call __str__ on the default value. Use lazy logging arguments at the two proven sites. Retain value identity, explicit overrides, false/zero/empty controls, and ordinary DEBUG-enabled message text.
Add targeted tests for registration, constructor-default resolution, and decorated construction. Broad lint adoption is not required.
Actual Results
Registration raises RuntimeError after retaining the value. In the full public-API probe, a nonthrowing counted object receives cumulative __str__ calls of 1, 2, and 3 across registration, resolution, and construction, while DEBUG is disabled. A throwing object also prevents the decorated constructor from entering; explicit injection succeeds.
Only custom synthetic values were exercised; no built-in plugin failure or production-frequency claim. A throwing __str__ at actual DEBUG emission is outside this disabled-logging fix.
Screenshots
N/A.
Versions
Linux; Python 3.12.3; actual default APIs and standard-library logging at PyRIT revision 01ce6ca66a315770b36c7dca1f320668c0d92d7c. Standalone offline probes; existing pytest suites were not run. No provider, memory backend, or initialization workflow was exercised. Full package-version output was not collected.
Activity
akhil9tiet commentedon Nov 4, 2026
I'd like to work on this — please assign it to me.
fix: use lazy logging args in apply_defaults debug logs
test: add regression coverage for lazy default-value logging