core: fix Provider serializer optional fields (#20289)

core/api: fix Provider serializer optional fields

Fixes #9787

The assigned_backchannel_application_slug and assigned_backchannel_application_name
fields in the Provider serializer were causing Pydantic validation errors in the
Python client when these fields returned None values.

Added required=False to these ReadOnlyField definitions to correctly mark them
as optional in the OpenAPI schema, allowing the Python client to handle None values.

Also applied the same fix to assigned_application_slug and assigned_application_name
for consistency.

Co-authored-by: Natalie Landsberg <natalie.landsberg@ericsson.com>
Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
This commit is contained in:
Natalie Landsberg
2026-08-24 08:33:09 -04:00
committed by GitHub
parent 61d4bf80c8
commit a65f481cd6

View File

@@ -18,13 +18,17 @@ from authentik.core.models import Provider
class ProviderSerializer(ModelSerializer, MetaNameSerializer):
"""Provider Serializer"""
assigned_application_slug = ReadOnlyField(source="application.slug", allow_null=True)
assigned_application_name = ReadOnlyField(source="application.name", allow_null=True)
assigned_application_slug = ReadOnlyField(
source="application.slug", allow_null=True, required=False
)
assigned_application_name = ReadOnlyField(
source="application.name", allow_null=True, required=False
)
assigned_backchannel_application_slug = ReadOnlyField(
source="backchannel_application.slug", allow_null=True
source="backchannel_application.slug", allow_null=True, required=False
)
assigned_backchannel_application_name = ReadOnlyField(
source="backchannel_application.name", allow_null=True
source="backchannel_application.name", allow_null=True, required=False
)
component = SerializerMethodField()