Skip to content
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

Closed
1 task done
rumiha opened this issue Jun 5, 2024 · 2 comments
Assignees
Labels
bug An issue with the system

Comments

@rumiha
Copy link

rumiha commented Jun 5, 2024

📜 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 the onSubmit method. Function slugs.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 because Test Category will not be found with slugs.indexOf(category) since the slug is test-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

  1. Created new category
    image

  2. Category created, but slug is different from title
    image

  3. Creating new announcement and selecting created category
    image

  4. Clicking submit button and getting error
    image

👟 Reproduction steps

  1. Created new category
  2. Category created, but slug is different from title
  3. Creating new announcement and selecting created category
  4. Clicking submit button and getting error

📃 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?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

@rumiha rumiha added the bug An issue with the system label Jun 5, 2024
@lavanya-sainik-ericsson
Copy link
Contributor

Hey All,

We would like to provide a fix for this bug and contribute in this plugin. Will share the PR soon for review.

lavanya-sainik-ericsson pushed a commit to lavanya-sainik-ericsson/backstage-plugin-announcements that referenced this issue Jun 18, 2024
lavanya-sainik-ericsson pushed a commit to lavanya-sainik-ericsson/backstage-plugin-announcements that referenced this issue Jun 27, 2024
kurtaking added a commit that referenced this issue Jul 9, 2024
…vent the announcement from being created #351 (#360)

* Update internal dependencies (#370)

* Bug Fix: Creating a category with a different slug and title will prevent the announcement from being created #351

Signed-off-by: elavsai [email protected]

* Bug Fix: Creating a category with a different slug and title will prevent the announcement from being created

Signed-off-by: elavsai [email protected]

* fix: yarn lockfile

Signed-off-by: Kurt King <[email protected]>

---------

Signed-off-by: elavsai [email protected]
Signed-off-by: Kurt King <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Kurt King <[email protected]>
@kurtaking
Copy link
Member

@lavanya-sainik-ericsson @rumiha -

@lavanya-sainik-ericsson's fix for this is in the latest release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug An issue with the system
Projects
None yet
3 participants