Skip to content

FIX Stop using deprecated AttackResult.attack_identifier in attack_service#1644

Open
romanlutz wants to merge 1 commit intomicrosoft:mainfrom
romanlutz:fix/remove-deprecated-attack-identifier-usage
Open

FIX Stop using deprecated AttackResult.attack_identifier in attack_service#1644
romanlutz wants to merge 1 commit intomicrosoft:mainfrom
romanlutz:fix/remove-deprecated-attack-identifier-usage

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

Summary

Migrate attack_service.py away from the deprecated AttackResult.attack_identifier property (scheduled for removal in 0.15.0).

Changes

Production code (pyrit/backend/services/attack_service.py):

  • Replace ar.attack_identifier with ar.get_attack_strategy_identifier() (the non-deprecated equivalent)
  • Stop writing the deprecated attack_identifier key in update_fields during converter merging — only atomic_attack_identifier (the source of truth) is now updated

Tests (tests/unit/backend/test_attack_service.py, tests/unit/memory/test_memory_models.py):

  • Update existing assertions to use get_attack_strategy_identifier() and check atomic_attack_identifier in update_fields
  • Add test for flat/legacy atomic identifier fallback converter merge path
  • Add assertion that deprecated attack_identifier column is not written to update_fields
  • Add test proving DB read prefers atomic_attack_identifier over stale attack_identifier

Why this is safe

  • AttackResult.attack_identifier just delegates to get_attack_strategy_identifier() — identical return value
  • All attacks (GUI-created and scenario-based) always set atomic_attack_identifier
  • Legacy DB rows without atomic_attack_identifier get it reconstructed on read via AttackResultEntry.get_attack_result()
  • The attack_identifier DB column becoming stale is harmless: get_attack_result() always prefers atomic_attack_identifier

Eliminates ~42 DeprecationWarning emissions during unit tests.

Replace ar.attack_identifier with ar.get_attack_strategy_identifier() in
attack_service.py. Remove writing the deprecated attack_identifier DB column
in _update_attack_after_message_async — only atomic_attack_identifier (the
source of truth) is now updated.

Add tests for:
- Flat/legacy atomic identifier fallback converter merge path
- Deprecated attack_identifier column not written to update_fields
- DB read prefers atomic_attack_identifier over stale attack_identifier

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz changed the title Stop using deprecated AttackResult.attack_identifier in attack_service FIX Stop using deprecated AttackResult.attack_identifier in attack_service Apr 22, 2026
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.

2 participants