Skip to content

Unfriendly Error Message When Updating Non-Existent Campaign via PUT /api/v1/settings/marketing/campaigns/{id} #157

Description

@sagarkumar-webkul

Title:

Unfriendly Error Message When Updating Non-Existent Campaign via PUT /api/v1/settings/marketing/campaigns/{id}

Description:

When attempting to update a marketing campaign using an ID that does not exist, the API returns a 404 with an internal exception trace. This is not user-friendly and exposes internal paths and classes.

Affected Endpoint:

  • PUT /api/v1/settings/marketing/campaigns/{id}

Preconditions:

  • Campaign ID 34 does not exist in the system.

Steps to Reproduce:

  1. Execute the following PUT request:
curl -X PUT 'http://<host>/api/v1/settings/marketing/campaigns/34' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
  "name": "Spring Sale",
  "subject": "Get Ready For Our Biggest Sale of the Year!",
  "status": "1",
  "marketing_template_id": "1",
  "marketing_event_id": "8"
}'
  1. Ensure ID 34 does not exist.
  2. Observe the server response.

Actual Result:

{
  "message": "No query results for model [Webkul\\Marketing\\Models\\Campaign] 34",
  "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
  ...
}

Expected Result:

  • A clean error message:
{
  "message": "Campaign with ID 34 not found.",
  "status": 404
}

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