Validation: ignore the '_meta' property

we've observed that this is sent-in-practice. we don't want to
actually remove it from the stored data, so we remove it only
from the thing we validate (not the actual data)
This commit is contained in:
Klaas van Schelven
2024-09-19 11:20:08 +02:00
parent fe9aba5c7d
commit d0eb6bea95

View File

@@ -132,15 +132,17 @@ class BaseIngestAPIView(View):
# ValidatorClass.check_schema(event_schema)
cls._event_validator = ValidatorClass(event_schema)
data_to_validate = {k: v for k, v in data.items() if k != "_meta"}
if validation_setting == "strict":
try:
cls._event_validator.validate(data)
cls._event_validator.validate(data_to_validate)
except jsonschema.ValidationError as e:
raise ValidationError(understandable_json_error(e), code="invalid_event_data") from e
else: # "warn"
try:
cls._event_validator.validate(data)
cls._event_validator.validate(data_to_validate)
except jsonschema.ValidationError as e:
logger.warn("event data validation failed: %s", understandable_json_error(e))