Skip to content

Trying to create a destination with a name that is already in use causes 500 error #930

@stveit

Description

@stveit

This was tested via the Argus react frontend.

Backend v.1.16.0, API v1(stable), frontend v.1.14.1

The API returns a 500 error if you try to create a destination that has the same name, media type and belongs to the same user.

Steps to reproduce (example using email media, but should be the same for all media):

  1. Go to /destinations page
  2. Create an email destination with a name so the "title" field should not be empty (multiple destinations with a blank doesnt seem to cause any issues)
  3. Try to create another email destination with a unique and valid email address, but the same name as the first destination
  4. API will reply with a 500 error code

I'm pretty sure the error is caused by a this constraint:

models.UniqueConstraint(fields=["user", "media", "label"], name="unique_label_per_user_and_medium"),

API tries to save via the serializer, but an exception is thrown as the constraint is not met. The error is not handled anywhere so it ends in a 500 error.

Expected behaviour

I expected to see this happen: Probably a 400 code reply with the error message "Destination label must be unique per media", or something along those lines

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedAnother thing/issue has to be resolved before tackling thisbugSomething is not working as expected

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions