-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Title:
Internal Server Error (500) When Fetching Non-Existent Marketing Event /api/v1/settings/marketing/events/{id}
Description:
When attempting to fetch a marketing event using an invalid or non-existent ID, the API returns a 500 Internal Server Error with the message:
"Attempt to read property 'id' on null".
This is misleading and exposes internal error handling issues instead of providing a clean API response.
Affected Endpoint:
GET /api/v1/settings/marketing/events/{id}
Preconditions:
- Krayin REST API is installed and authenticated.
- Marketing event with the specified ID does not exist.
Steps to Reproduce:
- Send a
GETrequest to/api/v1/settings/marketing/events/12(assuming ID 12 does not exist). - Observe the response.
Actual Result:
- HTTP 500 Internal Server Error
{
"message": "Attempt to read property 'id' on null",
"exception": "ErrorException",
...
}Expected Result:
- HTTP 404 Not Found
{
"message": "Marketing event with ID 12 not found.",
"status": 404
}Suggested Fix:
- Check if the marketing event exists before trying to access properties.
- Catch
ModelNotFoundExceptionor explicitly return a404when the record is not found. - Ensure Laravel debug mode (
APP_DEBUG) is disabled in production to prevent stack trace exposure.
Benefit:
- Provides a clean and accurate error message to API consumers.
- Prevents exposure of internal application logic.
- Aligns with standard REST API practices.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels