mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
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:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user