Skip to content

Unfriendly Error Message for Invalid Webhook ID on DELETE /api/v1/settings/webhooks/{id} #150

@sagarkumar-webkul

Description

@sagarkumar-webkul

Title:

Unfriendly Error Message for Invalid Webhook ID on DELETE /api/v1/settings/webhooks/{id}

Description:

When attempting to delete a webhook using a non-existent ID, the API returns a detailed Laravel exception message. This is not suitable for production as it exposes internal code structure and is not user-friendly.

Affected Endpoint:

  • DELETE /api/v1/settings/webhooks/{id}

Preconditions:

  • Krayin REST API installed and running.
  • Valid token and headers (if required).

Steps to Reproduce:

  1. Send a DELETE request to /api/v1/settings/webhooks/16 (assuming ID 16 does not exist).
  2. Observe the response.

Actual Result:

{
  "message": "No query results for model [Webkul\\Automation\\Models\\Webhook] 16",
  "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
  ...
}

Expected Result:

A cleaner and user-oriented JSON response, for example:

{
  "message": "Webhook with ID 16 not found.",
  "status": 404
}

Suggested Fix:

  • Catch ModelNotFoundException in the controller or globally.
  • Return a user-friendly message such as "Webhook with ID {id} not found.".
  • Ensure APP_DEBUG=false in .env to suppress trace output in production.

Benefit:

  • Provides a clean API interface for clients.
  • Avoids exposing internal Laravel paths or stack traces.

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