Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Do not mutate the relationshipsTypes array. #692

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

akashgp09
Copy link
Contributor

@akashgp09 akashgp09 commented Aug 24, 2021

Problem

Uncaught TypeError: Cannot set property 'attributes' of undefined

Steps to reproduce:

  1. Navigate to /series/create endpoint.
  2. Add a relationship.
  3. Then add a series item.

Cause:

When you add a relationship, the relationshipTypes array gets mutated here and the relationship type 69-74 is permanently removed. And then when you come back to the series editor, and tries to add a item to the series, the relationship type 69-74 is not present this time in the relationshipTypes array here, hence leading to an error.

Solution

Do not mutate the relationshipsTypes array.

Areas of Impact

https://github.com/bookbrainz/bookbrainz-site/blob/series-entity/src/client/entity-editor/relationship-editor/relationship-editor.tsx

Copy link
Member

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, good fix!

Do we have a similar situation here or is the mutation required?: https://github.com/bookbrainz/bookbrainz-site/blob/series-entity/src/server/helpers/middleware.ts#L83

@MonkeyDo MonkeyDo merged commit 2bfb6e0 into metabrainz:series-entity Aug 26, 2021
@akashgp09
Copy link
Contributor Author

akashgp09 commented Aug 26, 2021

Do we have a similar situation here or is the mutation required?: https://github.com/bookbrainz/bookbrainz-site/blob/series-entity/src/server/helpers/middleware.ts#L83

Yeah, mutating the array there is intentional. It will remove the series items from the relationships array, so that series items do not show up in the Relationships section of Series page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants