-
Notifications
You must be signed in to change notification settings - Fork 14
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
Update sds schema validation #1538
base: main
Are you sure you want to change the base?
Conversation
…order for it to be validated
…o if a schema doesn't include it, no error is raised
…t schema version in sds payload
@@ -80,12 +71,19 @@ def validate_dataset_and_survey_id( # pylint: disable=unused-argument | |||
"Supplementary data did not return the specified Survey ID" | |||
) | |||
|
|||
if self.context["sds_schema_version"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can merge the nested if here. Also data["data"]
is a bit weird but not sure there is a way around it
"survey_id": "123", | ||
"title": "Test Supplementary Data", | ||
"theme": "default", | ||
"description": "A questionnaire to demo using Supplementary data for placeholders, validation and routing in both repeating and non repeating sections.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would update the description here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new schema is not actually being used anywhere?
app/routes/session.py
Outdated
@@ -177,6 +177,7 @@ def _set_questionnaire_supplementary_data( | |||
dataset_id=new_sds_dataset_id, | |||
identifier=identifier, # type: ignore | |||
survey_id=metadata["survey_id"], # type: ignore | |||
sds_schema_version=schema.json.get("sds_schema_version", None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As .get()
implicitly returns None
if the key isn't found, might not need to override the output here?
if self.context["sds_schema_version"]: | ||
if data["data"]["schema_version"] != self.context["sds_schema_version"]: | ||
raise ValidationError( | ||
"The Supplementary Dataset version does not match the version set in the questionnaire schema" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V minor - To fit with the wording in the other exceptions, could maybe tweak this to match the wording for sds_schema_version
, so like The Supplementary Dataset Schema version does not match the questionnaire schema version
? Or something similar just to add a bit more description?
What is the context of this PR?
To align with SDS & Author we need to update the validation rules for supplementary data schema versions within Runner in order to support future automation of the releases of new SDS schema versions.
supplementary_data_parser
previously used a list of known versions but this will become unmanageable with several versions. Instead, we compare thesds_schema_version
set in a questionnaire schema to theschema_version
found in the supplementary data payload. We passsds_schema_version
fromsession.py
tosupplementary_data_parser
for it to be validated. The old logic has been removed and tests have been updated/added to show this change.A new schema has been added called
test_supplementary_data_with_sds_schema_version.json
to include this new field.How to review
Checklist