Repository navigation
FIX: return 409 Conflict when add_message hits AttackStateConflictError - #4688
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
Signed-off-by: ManoharPaturi <186662190+ManoharPaturi@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change to return HTTP 409 on message state conflicts.
No open issues 🎉
What changed in this PR
Fixes #4685 by returning HTTP 409 Conflict when adding a message raises AttackStateConflictError, matching related attack endpoints.
Changes:
- Handles state conflicts before the generic
ValueErrorhandler to prevent incorrect400 Bad Requestresponses. - Adds a regression case for the expected
409response.
| File | Description |
|---|---|
tests/unit/backend/test_api_routes.py |
Adds AttackStateConflictError to the route’s exception-mapping tests. |
pyrit/backend/routes/attacks.py |
Maps both state and manual-send conflicts to HTTP 409. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4685
POST /api/attacks/{attack_result_id}/messagesnow returns HTTP409 Conflictwhenadd_message_asyncraisesAttackStateConflictError, matchingapply_chat_scorer_async,save_conversation_async, andsubmit_message_send_async.(AttackStateConflictError, ManualSendConflictError)inadd_messagebefore the genericValueErrorhandler, sinceAttackStateConflictErrorsubclassesValueErrorBefore, when
add_message_asyncraisedAttackStateConflictError:After, on the same conflict: