Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion keep/api/routes/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,10 @@ def merge_incidents(

if failed_ids:
message += f", {pluralize(len(failed_ids), 'incident')} failed to merge"
raise HTTPException(f"Some incidents failed to merge. {message}")
raise HTTPException(
status_code=500,
detail=f"Some incidents failed to merge. {message}",
)

return MergeIncidentsResponseDto(
merged_incident_ids=merged_ids,
Expand Down
22 changes: 22 additions & 0 deletions tests/test_incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,28 @@ def test_merge_incidents_app(
"""


@pytest.mark.parametrize("test_app", ["NO_AUTH"], indirect=True)
def test_merge_incidents_app_reports_partial_failure(client, test_app):
source_id = uuid4()
destination_id = uuid4()

with patch(
"keep.api.routes.incidents.merge_incidents_to_id",
return_value=([], [source_id]),
):
response = client.post(
"/incidents/merge",
headers={"x-api-key": "some-key"},
json={
"source_incident_ids": [str(source_id)],
"destination_incident_id": str(destination_id),
},
)

assert response.status_code == 500
assert "failed to merge" in response.json()["detail"]


@pytest.mark.asyncio
async def test_split_incident(db_session, create_alert):
# Create source incident with multiple alerts
Expand Down
Loading