Title:
Unfriendly Error Message on Updating Non-Existent Marketing Event via PUT /api/v1/settings/marketing/events/{id}
Description:
When sending a PUT request to update a marketing event using a non-existent ID, the API returns a 404 response with a verbose Laravel exception message. This is not user-friendly and should be handled gracefully with a clear, concise message.
Affected Endpoint:
PUT /api/v1/settings/marketing/events/{id}
Preconditions:
- Krayin REST API is up and authenticated.
- Event with the provided ID does not exist in the database.
Steps to Reproduce:
- Send a
PUT request to /api/v1/settings/marketing/events/45 (assuming ID 45 does not exist).
- Include a valid JSON payload in the request body.
- Observe the response.
Actual Result:
{
"message": "No query results for model [Webkul\\Marketing\\Models\\Event] 45",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
...
}
Expected Result:
{
"message": "Marketing event with ID 45 not found.",
"status": 404
}
Suggested Fix:
- Catch
ModelNotFoundException in the controller or middleware.
- Return a clean 404 JSON response instead of a stack trace.
- Ensure
APP_DEBUG=false in production to avoid leaking internal paths.
Benefit:
- Provides a proper API experience for developers.
- Aligns with RESTful standards.
- Prevents exposure of internal Laravel implementation details.
Title:
Unfriendly Error Message on Updating Non-Existent Marketing Event via
PUT /api/v1/settings/marketing/events/{id}Description:
When sending a
PUTrequest to update a marketing event using a non-existent ID, the API returns a 404 response with a verbose Laravel exception message. This is not user-friendly and should be handled gracefully with a clear, concise message.Affected Endpoint:
PUT /api/v1/settings/marketing/events/{id}Preconditions:
Steps to Reproduce:
PUTrequest to/api/v1/settings/marketing/events/45(assuming ID 45 does not exist).Actual Result:
{ "message": "No query results for model [Webkul\\Marketing\\Models\\Event] 45", "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException", ... }Expected Result:
{ "message": "Marketing event with ID 45 not found.", "status": 404 }Suggested Fix:
ModelNotFoundExceptionin the controller or middleware.APP_DEBUG=falsein production to avoid leaking internal paths.Benefit: