Skip to content

[ENG-9824] - Add required metadata validation#11691

Open
Vlad0n20 wants to merge 2 commits intoCenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:feature/ENG-9824
Open

[ENG-9824] - Add required metadata validation#11691
Vlad0n20 wants to merge 2 commits intoCenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:feature/ENG-9824

Conversation

@Vlad0n20
Copy link
Copy Markdown
Contributor

@Vlad0n20 Vlad0n20 commented Apr 10, 2026

Ticket

Purpose

Changes

Side Effects

QE Notes

CE Notes

Documentation

Comment thread osf/models/provider.py Outdated
self.save()

def validate_required_metadata(self, osf_obj):
from jsonschema import validate, ValidationError as JsonSchemaValidationError
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this import hasn't any dependencies and we can move it to the top of the file


def test_missing_record_raises(self, provider, cedar_template, preprint):
provider.required_metadata_template = cedar_template
provider.save()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious as I'm not familiar with this functionality yet. Shouldn't we call validate_required_metadata during save call to prevent saving cedar template without cedar metadata record existence?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method validates a specific osf_obj (preprint/node) against the provider's required template — not the provider itself. It's intended to be called at publish/submission time for a given object (e.g. before a preprint goes public). Calling it in Provider.save() wouldn't make sense since there's no single object to validate there — a provider may have thousands of associated preprints.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants