Skip to content

FIX: warn when selected techniques have no registered factory - #2462

Closed
fei (feiiiiii5) wants to merge 6 commits into
microsoft:mainfrom
feiiiiii5:fix/warn-unresolved-techniques
Closed

FIX: warn when selected techniques have no registered factory#2462
fei (feiiiiii5) wants to merge 6 commits into
microsoft:mainfrom
feiiiiii5:fix/warn-unresolved-techniques

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Root Cause

resolve_technique_factories() in pyrit/scenario/core/matrix_atomic_attack_builder.py silently drops selected techniques that have no registered factory: the dict comprehension filters on technique.value in all_factories with no signal. A scenario selecting ["a", "b", "c"] where "b" is unregistered runs with 2 of 3 techniques and no indication that the selection was partially ignored (#2461).

Fix

Collect the missing selections and emit a warning listing them, consistent with how scenarios/adaptive/adaptive_scenario.py already warns when it skips techniques (skipped_incompatible + logger.warning). Behaviour is otherwise unchanged — the drop itself stays, since proceeding with whatever factories exist is the documented intent.

Test

  • New regression test test_warns_when_selected_technique_has_no_factory asserts the warning names the dropped technique.
  • Note: local pytest run is blocked by an optional dependency (deepeval) missing from this machine's environment; syntax-verified locally and CI will arbitrate the full suite.

Diff Scope

  • pyrit/scenario/core/matrix_atomic_attack_builder.py: + missing-selection warning
  • tests/unit/scenario/core/test_matrix_atomic_attack_builder.py: + regression test

Development was AI-assisted with human review of all changes.

Fixes #2461

JsonSchemaResponseHandler with numeric_value=True validated the value
with a bare float() cast, so "nan", "inf" and "-inf" strings passed as
valid scores. Float-scale aggregation then clamps with
max(0.0, min(1.0, x)); since every comparison against NaN is False,
min(1.0, nan) returns 1.0 and a NaN judge response silently aggregates
toward the maximum harm score instead of surfacing an error.

Treat non-finite parsed values as invalid scoring responses via
math.isfinite. Regression tests cover the five accepted spellings.

Fixes microsoft#2458

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
… them as auth-disabled

fetchAuthConfig collapsed both non-2xx responses and network errors into
an empty AuthConfig, which AuthProvider interpreted as "authentication
disabled". When /api/auth/config failed transiently while protected APIs
returned 401, the app rendered the normal shell with raw "Missing or
invalid Authorization header" text and no login control or error surface
(microsoft#2441).

The two failure paths now throw so the existing AuthProvider catch
renders its Authentication Error page. A 200 response with an empty
config still means auth is disabled (local dev), unchanged.

Fixes microsoft#2441

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
resolve_technique_factories silently dropped selected techniques that
have no registered factory, so a scenario selecting ["a", "b", "c"]
where "b" is unregistered ran with 2 of 3 techniques and no indication
the selection was partially ignored (microsoft#2461).

Log a warning listing the dropped selections, matching how
adaptive_scenario.py already surfaces skipped techniques.

Fixes microsoft#2461

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
@feiiiiii5

Copy link
Copy Markdown
Contributor Author

Additional internal precedent found while auditing the scenario layer: scenarios/garak/web_injection.py (~L520) also warns per-technique when no prompts are generated ("No prompts generated for technique ...; skipping.") before raising only when all techniques produce nothing. So the warn-on-skip behaviour added here for resolve_technique_factories matches two existing sites, not one.

@romanlutz Roman Lutz (romanlutz) changed the title fix(scenario): warn when selected techniques have no registered factory FIX: warn when selected techniques have no registered factory Aug 22, 2026
Roman Lutz (romanlutz) and others added 2 commits August 22, 2026 06:53
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve docstring conflict in response_handler.py (take upstream wording).
auto-merge was automatically disabled August 22, 2026 15:41

Head branch was pushed to by a user without write access

@feiiiiii5

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2466 which has a cleaner diff (this PR accidentally included unrelated frontend auth files). #2466 covers the same fix with focused changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resolve_technique_factories silently drops selected techniques with no registered factory

2 participants