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:
Jens Langhammer 2023-02-01 19:45:36 +01:00
parent f2386f126e
commit dbf2bd5aba
No known key found for this signature in database
1 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,7 @@ from dacite.config import Config
from dacite.core import from_dict
from dacite.exceptions import DaciteError
from deepmerge import always_merger
from django.core.exceptions import FieldError
from django.db import transaction
from django.db.models import Model
from django.db.models.query_utils import Q
@ -181,7 +182,10 @@ class Importer:
if not query:
raise EntryInvalidError("No or invalid identifiers")
try:
existing_models = model.objects.filter(query)
except FieldError as exc:
raise EntryInvalidError(f"Invalid identifier field: {exc}") from exc
serializer_kwargs = {}
model_instance = existing_models.first()