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
1 changed files with 3 additions and 0 deletions

View File

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