blueprints: handle error when blueprint entry identifier field does not exist
closes #4588 Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
f2386f126e
commit
dbf2bd5aba
|
@ -7,6 +7,7 @@ from dacite.config import Config
|
||||||
from dacite.core import from_dict
|
from dacite.core import from_dict
|
||||||
from dacite.exceptions import DaciteError
|
from dacite.exceptions import DaciteError
|
||||||
from deepmerge import always_merger
|
from deepmerge import always_merger
|
||||||
|
from django.core.exceptions import FieldError
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.db.models.query_utils import Q
|
from django.db.models.query_utils import Q
|
||||||
|
@ -181,7 +182,10 @@ class Importer:
|
||||||
if not query:
|
if not query:
|
||||||
raise EntryInvalidError("No or invalid identifiers")
|
raise EntryInvalidError("No or invalid identifiers")
|
||||||
|
|
||||||
|
try:
|
||||||
existing_models = model.objects.filter(query)
|
existing_models = model.objects.filter(query)
|
||||||
|
except FieldError as exc:
|
||||||
|
raise EntryInvalidError(f"Invalid identifier field: {exc}") from exc
|
||||||
|
|
||||||
serializer_kwargs = {}
|
serializer_kwargs = {}
|
||||||
model_instance = existing_models.first()
|
model_instance = existing_models.first()
|
||||||
|
|
Reference in New Issue