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

Fix genconfig does not fail when schema validation failed #425

Merged
merged 5 commits into from
Mar 27, 2020

Conversation

blackchoey
Copy link
Collaborator

@blackchoey blackchoey commented Mar 13, 2020

Fix genconfig does not fail when schema validation failed #424
AB#1696447

@blackchoey blackchoey requested a review from adashen March 13, 2020 05:59
@@ -190,6 +190,9 @@ def _validate_json_schema(self, schema_object, json_object, schema_type):
self.output.warning("%s schema validation failed. Please see previous logs for more details" % schema_type)
else:
self.output.info("%s schema validation passed." % schema_type)

if error_detected:
Copy link

Choose a reason for hiding this comment

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

line 189 has if error_detected?

Copy link

Choose a reason for hiding this comment

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

besides it already has error_detected, do we still need validation_success?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the error_detected and reuse validation_success. We need to declare validation_success outside of try to handle situations with exception.

Copy link

Choose a reason for hiding this comment

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

removed error_detected? we have two blocks of error_detected (189 and 194)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the commit that removes error_detected, I removed both of them and use validation_success instead: 60cac66

@@ -146,7 +146,7 @@ def validate_deployment_template(self):
validation_success = True
try:
template_schema = json.loads(urlopen(Constants.deployment_template_schema_url).read().decode())
self._validate_json_schema(template_schema, self.json, "Deployment template")
validation_success = self._validate_json_schema(template_schema, self.json, "Deployment template")
except Exception as ex: # Ignore other non shcema validation errors
self.output.info("Unexpected error during deployment template schema validation, skip schema validation. Error:%s" % ex)
Copy link

Choose a reason for hiding this comment

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

exception happens and the validation is still success?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only schema failures should be treated as validation failure. Other exceptions such as network error should not fail the validation. iotedgedev will only print related error and skip validation.

@blackchoey
Copy link
Collaborator Author

blackchoey commented Mar 13, 2020

Some Azure CLI modules breaks the automation test, I will investigate and see whether I can provide a quick fix

@blackchoey blackchoey merged commit abebb95 into master Mar 27, 2020
@EliiseS EliiseS deleted the chyuan/fix-validation-not-fail branch September 6, 2021 11:24
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