goauthentik / goauthentik/authentik

[Bug]: Missing API validation for user field on LDAP User Connection creation causes 500 Error

Open Beginner friendly
#25,673 2 comments 0 reactions 0 assignees View on GitHub
bug/confirmed
Dominant language
Python
Stars
25.6k
Forks
2k
Avg merge
1d 2h
Merged PRs (30d)
651

Description

### Describe the bug

The `/api/v3/sources/user_connections/ldap/` endpoint lacks serializer validation for the required `user` field. If a POST request is sent without this field (or if the UI drops it), the API passes `null` to the database instead of catching the missing field. This results in a PostgreSQL `IntegrityError` (violating the `not-null` constraint) and a hard `500 Internal Server Error` rather than a graceful `400 Bad Request`.

### How to reproduce

1. Send a POST request to `/api/v3/sources/user_connections/ldap/` omitting the `user` field (or use the Authentik UI which currently suffers from a bug that drops this field).
2. Observe the `500 Internal Server Error` in the API response and server logs.

### Expected behavior

The API serializer should validate that `user` is provided in the payload. If missing, it should return a `400 Bad Request` explicitly stating that the user field is required, preventing a database constraint violation.

### Screenshots

_No response_

### Additional context

This was discovered because the Authentik UI currently fails to pass the selected user when submitting the form, immediately triggering this backend crash.

### Deployment Method

Docker

### Version

2026.8.1

### Relevant log output

```shell
// PostgreSQL Log:
postgresql-1 | ERROR: null value in column "user_id" of relation "authentik_core_usersourceconnection" violates not-null constraint
postgresql-1 | DETAIL: Failing row contains (587, 2026-09-02 07:10:11.116352+00, 2026-09-02 07:10:11.116374+00, f220ba0b-87b9-4bfb-8d35-642956a105cd, null, S-1-5-21-3638675543-1746918860-1899855899-1109).

// Authentik Server Log:
{"event": "Internal Server Error: /api/v3/sources/user_connections/ldap/", "exception": [{"exc_type": "IntegrityError", "exc_value": "null value in column \"user_id\" of relation \"authentik_core_usersourceconnection\" violates not-null constraint..."]}]}
```

Contributor guide

Open the contributing guide

Research direction

Start at the serializer handling POST requests for /api/v3/sources/user_connections/ldap/ and trace how a missing user field reaches PostgreSQL. Reproduce the request without user and verify that validation returns a 400 Bad Request identifying user as required, without an IntegrityError or 500 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
api, authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.