optimizely/python-sdk

raise exception when validating datafile and datafile is not valid

zhammer opened this issue · 2 comments

would it be possible to send an exception to the error handler when schema validation is enabled but the datafile provided is not valid? current behavior is log error but continue as is.

if self.validate_schema:
if not validator.is_datafile_valid(datafile):
self.logger.error(enums.Errors.INVALID_INPUT.format('datafile'))
return

Thank you @zhammer . Looking into it.
There may be considerations around consistency inside Py sdk as well with other SDKs.
Also how expensive the change would be, also seems like an be an API change.

@zhammer My assumption is that you would like to be informed in real time if datafile validation failed?
Yes, you can set the logger to show the error, but that's not it.

You could use Decide API in the SDK to display reasons. We return null variation and error message in real-time (in reasons when config fails).
For example set options = [DecideOption.INCLUDE_REASONS] and then call reasons on your decision like so decision.reasons.
You should get the error message: 'Optimizely SDK not configured properly yet.'
Would that work?

Changing log error to raising an exception would unfortunately be a breaking change for the API which is a significant task for the moment.