pentacent / keila

Open Source Newsletter Tool.
https://keila.io
GNU Affero General Public License v3.0
1.38k stars 70 forks source link

Internal server error on deleted campaign link #311

Closed dompie closed 3 months ago

dompie commented 3 months ago

After deleting a campaign in Keila, a link from an email can be still clicked. If done so, the user will see only a blank page with the message "Internal server error" and the following error happens in docker logs:

12:50:08.350 [error] #PID<0.4409962.0> running KeilaWeb.Endpoint (connection #PID<0.4409963.0>, stream id 2) terminated
Server: newsletter.frivol.com:80 (http)
Request: GET /c/https%253A%252F%252Fwww.domain.com252Fprofil%252Fabc123/nmr_d8rKBBL4/ntl_BzLMeaLX/TsAVxrq6cA3sdZT5MKcz3fYItSGsBsYp3_wwbno07F4
** (exit) an exception was raised:
    ** (Ecto.ConstraintError) constraint error when attempting to insert struct:

    * "tracking_clicks_link_id_fkey" (foreign_key_constraint)

If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `foreign_key_constraint/3` on your changeset with the constraint
`:name` as an option.

The changeset has not defined any constraint.

        (ecto 3.10.1) lib/ecto/repo/schema.ex:804: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
        (elixir 1.15.8) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
        (ecto 3.10.1) lib/ecto/repo/schema.ex:788: Ecto.Repo.Schema.constraints_to_errors/3
        (ecto 3.10.1) lib/ecto/repo/schema.ex:769: Ecto.Repo.Schema.apply/4
        (ecto 3.10.1) lib/ecto/repo/schema.ex:377: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
        (ecto 3.10.1) lib/ecto/repo/schema.ex:273: Ecto.Repo.Schema.insert!/4
        (keila 0.14.9) lib/keila/tracking/tracking.ex:134: Keila.Tracking.track_click_and_get_link/5
        (keila 0.14.9) lib/keila_web/controllers/tracking_controller.ex:31: KeilaWeb.TrackingController.track_click/2

There should no "Internal Server Error" message be visible to the user.

Instead "Campaign does not exist anymore" or similar text would be more helpful.

wmnnd commented 3 months ago

Thanks for reporting this! There’s already a ticket for this under #210.