Closed lwrubel closed 2 years ago
see argo PRs for how this is done for argo registration.
Argo does the validation client-side; none of the existing validation of WRA is done client-side, so I'm not sure we want to introduce here. I'd suggest that server-side is good enough (and less complex).
If this error is occurring in a job, then it's possible that a server side validation says "This is okay", then kicks off a job and in the interrim another thread scoops up that sourceId. Would it make sense to do the registration synchronously, and then look for a 409 Conflict
response?
That sort of a race condition is unlikely; this is primarily to catch user error as close to form entry as possible.
Think of this as similar to the source id validation that is currently done in the Argo registration form.
The Argo registration form is synchronous. So Argo won't have that race condition.
Currently, if a duplicate sourceID is entered in the form for one-time registration, the job is created and the registration will fail. The error displayed in the jobs table on the home page is:
failure: Conflict (An object (druid:mt876jr1942) with the source ID 'wra-test:lwrubel-6' has already been registered.)
(Error from Honeybadger)
Update the form to validate that the source ID is unique before a registration is attempted and display an error in the form.
@justinlittman advised that this will likely involves setting up an endpoint on DSA to find a cocina object by source ID. (If the source ID is found, then the form is not valid.) dor-services-client would then also need to be updated to be able to use this endpoint.