Flagsmith / Flagsmith/flagsmith
Environment feature versions are not importable via `loaddata`
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 567
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 121
Description
**Symptom:** `loaddata` raises `DeserializationError` for any organisation that has an environment with `use_v2_feature_versioning = True`.
**Root cause:** `EnvironmentFeatureVersionManager` ([features/versioning/managers.py:16](https://github.com/Flagsmith/flagsmith/blob/main/api/features/versioning/managers.py#L16)) inherits from `SoftDeleteManager` but is missing `UUIDNaturalKeyManagerMixin`. Every other exportable manager in the codebase includes this mixin. Without it, Django serialises FK references to `EnvironmentFeatureVersion` (on `FeatureState.environment_feature_version` and `FeatureSegment.environment_feature_version`) as a natural-key list `[""]`, but the deserialiser cannot resolve the list back to an object because `get_by_natural_key` does not exist on the manager.
**Fix:** One-line change — add the mixin:
```python
class EnvironmentFeatureVersionManager(UUIDNaturalKeyManagerMixin, SoftDeleteManager):
```
This follows the exact pattern of `FeatureManager`, `FeatureStateManager`, `FeatureSegmentManager`, and `SoftDeleteExportableManager`.
**Test:** Use tests from https://github.com/Flagsmith/flagsmith/pull/6765 to verify the correctness of the solution.
Contributor guide
Assessment
This issue has not been assessed yet.