datacite / lupo

DataCite REST API
https://api.datacite.org
MIT License
11 stars 8 forks source link

`schemaVersion` is not populated when a DOI is created via REST API via JSON #1179

Open codycooperross opened 8 months ago

codycooperross commented 8 months ago

Describe the bug

When a DOI is created via REST API via JSON, the schemaVersion attribute is not populated and is returned as nil. When the DOI metadata is updated, the schemaVersion is correctly populated.

NOTE:

This was first noted in Fabrica. A user would create a DOI via the create form form with the assumption that Fabrica would use an appropriate default, since there was no way for the user to set this value. On going to the update DOI form, there would be a flash message at the top of the screen saying the schema version was out of date, and that on saving the update form, the DOI schema version would be updated to the latest.

The Fabrica create DOI form has been amended to set the DOI schema version to the latest version in https://github.com/datacite/bracco/pull/829 (Here: https://github.com/datacite/bracco/pull/829/files#diff-c1a0761549c6ea67bce6d2c46f34c97b22927b6d7fadf48f393a00f63fa89952)

Expected Behaviour

The schemaVersion is populated with the relevant schema version of the DOI metadata (currently, http://datacite.org/schema/kernel-4).

Current Behaviour

The schemaVersion is only populated after an update to the DOI metadata.

Steps to Reproduce

Create a DOI via JSON via REST API and check the response and DB values.

Context (Environment)

This results in a Using the Form would update this DOI to the latest schema version. message in Fabrica when updating a DOI using the form that has just been created.

Screenshots

Further details

Proposal

Hypothesis

The schemaVersion does not appear to be set either here:

https://github.com/datacite/lupo/blob/cde436d3f73626b867e671da80a0c8893016ed76/app/controllers/datacite_dois_controller.rb#L580-L588

Or here:

https://github.com/datacite/lupo/blob/cde436d3f73626b867e671da80a0c8893016ed76/app/lib/params_sanitizer.rb#L451-L458

Possible Implementation

Front logo Front conversations

codycooperross commented 6 months ago

@ashwinisukale Sarala asked if you have time to take a look at this bug. Let me know if you have any questions about it! There is some information here that might be helpful as well: https://docs.google.com/document/d/1MBFgPpb0Sl26ilX9PzXCnWmBNSQgDEQTBLL_u71iVlw/edit#heading=h.jzpcxpnjvsq