Skip to content

POST /api/v1/settings/marketing/events/mass-destroy Returns 200 Even When IDs Do Not Exist #155

Description

@sagarkumar-webkul

Title:

POST /api/v1/settings/marketing/events/mass-destroy Returns 200 Even When IDs Do Not Exist

Description:

The mass-destroy endpoint accepts an array of marketing event IDs to delete. However, if the given IDs do not exist, the API still returns a success response (200 OK) with the message:
"Marketing event deleted successfully."
This is misleading and should be handled with validation or a partial success message.

Affected Endpoint:

  • POST /api/v1/settings/marketing/events/mass-destroy

Preconditions:

  • Krayin REST API is running.
  • No event with ID 3 exists in the system (as shown in test).

Steps to Reproduce:

  1. Send a request to:
curl -X POST 'http://<host>/api/v1/settings/marketing/events/mass-destroy' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"indices": [3]}'
  1. Ensure ID 3 does not exist in the DB.
  2. Observe the response.

Actual Result:

{
  "data": {
    "message": "Marketing event deleted successfully."
  }
}

Expected Result:

  • Return a 422 Unprocessable Entity or a multi-status 207 response:
{
  "message": "Some records could not be deleted because they do not exist.",
  "deleted": [],
  "not_found": [3]
}

Suggested Fix:

  • Add validation to check if each ID exists before attempting delete.
  • Return proper status and feedback to indicate what was and wasn’t deleted.

Benefit:

  • Accurate response for better user experience and automation.
  • Prevents assumptions that non-existent records were removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions