Race conditions are met with HTTP 500 by Core API
#6.617 aberto em 28 de jan. de 2026
Métricas do repositório
- Stars
- (3.475 stars)
- Métricas de merge de PR
- (Mesclagem média 3d 7h) (157 fundiu PRs em 30d)
Description
We're regularly seeing IntegrityError logs (example below) pop up, often because of poorly orchestrated scripts or racing frontend code.
We should come up with a unified approach to these. The expectation is that the backend should handle the conflicts opaquely, or clearly indicate to the client why the request couldn't go through. Options are:
a) Consider wrapping mutating operations in transactions — unlikely outcome as we don't want to increase lock contention.
b) Return 409 Conflict — a bit tricky as it'd take some heuristics to accurately detect race-related IntegrityErrors.
Sentry Issue: FLAGSMITH-API-5GY
UniqueViolation: duplicate key value violates unique constraint "lowercase_feature_name"
DETAIL: Key (lower(name::text), project_id)=(pltn.objectbuilder.fixemptypagerace, 13318) already exists.
File "django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
IntegrityError: duplicate key value violates unique constraint "lowercase_feature_name"
DETAIL: Key (lower(name::text), project_id)=(pltn.objectbuilder.fixemptypagerace, 13318) already exists.
(29 additional frame(s) were not displayed)
...
File "features/views.py", line 270, in perform_create
serializer.save(
File "features/serializers.py", line 367, in create
feature = super().create(validated_data)
File "features/serializers.py", line 219, in create
instance = super(CreateFeatureSerializer, self).create(validated_data) # type: ignore[no-untyped-call]