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
GET request 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:
{
"message": "Marketing event with ID 12 not found.",
"status": 404
}
Suggested Fix:
- Check if the marketing event exists before trying to access properties.
- Catch
ModelNotFoundException or explicitly return a 404 when 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.
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:
Steps to Reproduce:
GETrequest to/api/v1/settings/marketing/events/12(assuming ID 12 does not exist).Actual Result:
{ "message": "Attempt to read property 'id' on null", "exception": "ErrorException", ... }Expected Result:
{ "message": "Marketing event with ID 12 not found.", "status": 404 }Suggested Fix:
ModelNotFoundExceptionor explicitly return a404when the record is not found.APP_DEBUG) is disabled in production to prevent stack trace exposure.Benefit: