sul-dlss / was-registrar-app

Rails app to organize downloaded web archiving data and trigger preassembly/accessioning when appropriate
0 stars 0 forks source link

Check whether source ID is unique before registering #471

Closed lwrubel closed 2 years ago

lwrubel commented 2 years ago

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.

ndushay commented 2 years ago

see argo PRs for how this is done for argo registration.

justinlittman commented 2 years ago

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).

jcoyne commented 2 years ago

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?

justinlittman commented 2 years ago

That sort of a race condition is unlikely; this is primarily to catch user error as close to form entry as possible.

justinlittman commented 2 years ago

Think of this as similar to the source id validation that is currently done in the Argo registration form.

jcoyne commented 2 years ago

The Argo registration form is synchronous. So Argo won't have that race condition.