events: sanitize enums (#5610)

when importing a flow and returning logs, sometimes an enum might be included which is currently not sanitized and hence causes an exception

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-05-15 14:39:58 +02:00 committed by GitHub
parent c3398004ff
commit ff1510dedc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
import re
from copy import copy
from dataclasses import asdict, is_dataclass
from enum import Enum
from pathlib import Path
from types import GeneratorType
from typing import Any, Optional
@ -126,6 +127,8 @@ def sanitize_item(value: Any) -> Any:
return str(value)
if isinstance(value, YAMLTag):
return str(value)
if isinstance(value, Enum):
return value.value
if isinstance(value, type):
return {
"type": value.__name__,