Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
codycooperross opened this issue Jan 18, 2024 · 1 comment · Fixed by #1182
Open

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

codycooperross opened this issue Jan 18, 2024 · 1 comment · Fixed by #1182

Comments

@codycooperross
Copy link
Contributor

codycooperross commented Jan 18, 2024

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 datacite/bracco#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:

if sanitized_params[:schema_version].blank?
@doi.assign_attributes(
sanitized_params.except(:doi, :client_id).merge(
schema_version: @doi[:schema_version] || LAST_SCHEMA_VERSION,
),
)
else
@doi.assign_attributes(sanitized_params.except(:doi, :client_id))
end

Or here:

def add_schema_version(hash)
@params[:schemaVersion] =
if METADATA_FORMATS.include?(hash["from"])
LAST_SCHEMA_VERSION
else
@params[:schemaVersion]
end
end

Possible Implementation

Front logo Front conversations

@codycooperross
Copy link
Contributor Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants