This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
🐛 Bug Report: Creating a category with a different slug and title will prevent the announcement from being created #351
Labels
bug
An issue with the system
📜 Description
Creating a category with a different slug and title will prevent an announcement from being created with that category selected. Attempting to create a new announcement with such a category will throw the following error:
backstage error Filtered internal error with logId=a4056554bf2c3b3194dc from response insert into "categories" ("slug", "title") values ($1, $2) - duplicate key value violates unique constraint "categories_pkey"
The problem is in
CreateAnnouncementPage.tsx
, inside theonSubmit
method. Functionslugs.indexOf(category)
will return -1 if the category slug and title are not the same, because it tries to find the category title inside an array of category slugs.For example, when creating a new announcement, if the user selects the category
Test Category
and presses the submit button, it will throw an error. This happens becauseTest Category
will not be found withslugs.indexOf(category)
since the slug istest-category
.👍 Expected behavior
The code should use the slug from the selected category (not the title) to successfully search the slug array.
👎 Actual Behavior with Screenshots
Created new category
Category created, but slug is different from title
Creating new announcement and selecting created category
Clicking submit button and getting error
👟 Reproduction steps
📃 Provide the context for the Bug.
No response
🖥️ Your Environment
No response
👀 Have you spent some time to check if this bug has been raised before?
Are you willing to submit PR?
None
The text was updated successfully, but these errors were encountered: