SSHOC / sshoc-marketplace-backend

Code for the backend
Apache License 2.0
2 stars 0 forks source link

enable to suggest new concepts to the keyword vocabulary #438

Closed laureD19 closed 4 months ago

laureD19 commented 4 months ago

trying to suggest new concept to the keyword vocabulary results in a 500 error, via front-end and via api "/api/vocabularies/sshoc-keyword/concepts"

result = { "timestamp": "2024-02-27 10:57:10", "status": 500, "error": "could not execute statement; SQL [n/a]; constraint [unique_vocabulary_ord]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement" }

@mkrzmr also got the following result: { "timestamp": "2024-02-27 10:29:16", "status": 500, "error": "Request method 'POST' not supported" }

Could you investigate what is it about, @tparkola ?

Please complete the description where needed @mkrzmr @KlausIllmayer

notify also @vronk

mkrzmr commented 4 months ago

Same issue on stage and production

tparkola commented 4 months ago

Hi, I just checked dev (https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/vocabularies/sshoc-keyword/concepts) with POST method and the following JSON: { "code": "testTP", "label": "testTP", "definition": "testTP" }

and it was added with the following response:

{ "code": "testTP", "vocabulary": { "code": "sshoc-keyword", "scheme": "https://vocabs.sshopencloud.eu/vocabularies/sshomp-keyword/", "namespace": "https://vocabs.sshopencloud.eu/vocabularies/sshomp-keyword/", "label": "Keywords from SSHOMP", "closed": false }, "label": "testTP", "notation": "", "definition": "testTP", "uri": "https://vocabs.sshopencloud.eu/vocabularies/sshomp-keyword/testTP", "candidate": true, "relatedConcepts": [] }

Now GET (https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/vocabularies/sshoc-keyword/concepts/testTP) provides proper response about the added concept.

Could you check your request or let me know what is the request you are sending? Please be aware of the recent changes related to ord (especially in https://github.com/SSHOC/sshoc-marketplace-backend/issues/420).

KlausIllmayer commented 4 months ago

the logfiles say:

28-02-2024 08:48:12.426 [http-nio-8080-exec-7] WARN  o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - SQL Error: 0, SQLState: 23505
28-02-2024 08:48:12.426 [http-nio-8080-exec-7] ERROR o.h.e.jdbc.spi.SqlExceptionHelper.logExceptions - ERROR: duplicate key value violates unique constraint "unique_vocabulary_ord"
2024-02-28T08:48:12.427135393Z   Detail: Key (vocabulary_code, ord)=(sshoc-keyword, 2636) already exists.
28-02-2024 08:48:12.449 [http-nio-8080-exec-7] ERROR e.s.m.c.MarketplaceExceptionHandler.handleServerError - Runtime exception
2024-02-28T08:48:12.450541681Z org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [unique_vocabulary_ord]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
2024-02-28T08:48:12.450551352Z  at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:298)
2024-02-28T08:48:12.450557944Z  at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
...

maybe this is connected with the frontend? frontend sends POST to /api/vocabularies/sshoc-keyword/concepts?vocabularyCode=sshoc-keyword&candidate=true with the body {"label":"testagain","code":"testagain"}

btw @tparkola , please try to not use the url to the stage-server in GitHub issues as we like to prevent a mess by other users that maybe not get the difference to the production-server.

KlausIllmayer commented 4 months ago

Okay, I now see the difference. It works on the development server (@tparkola you used the URL to development and not so stage) but not on stage. If you try the same with stage you will get an error. The #420 was applied on stage, so maybe the reason is the way how the next free primary key identifier for concept is created?

KlausIllmayer commented 4 months ago

Seems that the problem is that we deleted a concept from sshoc-keyword so that calculating the ord-value to use gets confused. The call to DELETE /api/vocabularies/{vocabulary-code}/concepts/{code} should be checked against the mechanism of calculating the ord-value to use when creating a new concept. We must also think how do we deal with the current situation, which means that we may need to proceed again a script to update the ord-values.