acdh-oeaw / apis-core

https://acdh-oeaw.github.io/apis-core/
MIT License
11 stars 3 forks source link

new work types can’t be created #402

Closed laurauntner closed 1 year ago

laurauntner commented 1 year ago

concerns only work types (e. g. drama) in django, other entity types can be created

gregorpirgie commented 1 year ago

@laurauntner and @martinantonmueller - Does it not work for all new work types or when you try to create a specific new work type? If the latter, can you say which work type you tried to create (the name)?

From reading the sentry logs, the error seems to be that even prior to trying to create a specific work-type, there are already two work types existing with the same name (or a string that postgresql reads as the same string via collation). This throws an error and causes the crash.

gregorpirgie commented 1 year ago

Was it "Einzelne-Ausgabe" or related to a work type that uses this term?

laurauntner commented 1 year ago

@gregorpirgie no, it wasn’t a subtype or anything related to einzelne ausgabe. i tried to create a completely new type (novellette). i also tried to create the type kurzgeschichte which didn’t work either.

gregorpirgie commented 1 year ago

ok thanks! Will have another look.

laurauntner commented 1 year ago

thanks @gregorpirgie!

gregorpirgie commented 1 year ago

Issue is resolved, but for documentation purposes - here is the cause (and the solution):

Prior to saving a new WorkType (or any type that inherits from the VocabsBaseClass - model), the VocabNames model in apis_core.apis_vocabularies.models is called with a get_or_create. This model relates to the vocab_name field of the VocabsBaseClass - it stores the name of the model that the new Type belongs to, in this case "WorkType".

Issue was: There where two entries with the name "WorkType" in the VocabNames model, so the get_or_create raised an error. I connected to the Database directly, noticed that one of the two "WorkType" instances did not hold any relations to VocabsBaseClass and deleted this entry.

No idea what caused the duplicate entries in the first place, but this is the fix (if the issue should re-occur).