Flagsmith / Flagsmith/flagsmith

Clone environment fails to associate new feature segments with new feature states

Open
#2,511 1 comment 0 reactions 1 assignee Claimed by @matthewelwell View on GitHub
api bug
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 13h
Merged PRs (30d)
121

Description

Sentry Issue: [FLAGSMITH-API-35D](https://flagsmith.sentry.io/issues/4337123971/?referrer=github_integration)

```
ForeignKeyViolation: insert or update on table "features_featurestate" violates foreign key constraint "features_featurestat_feature_segment_id_547d5f48_fk_features_"
DETAIL: Key (feature_segment_id)=(37855) is not present in table "features_featuresegment".

File "django/db/backends/base/base.py", line 242, in _commit
return self.connection.commit()

IntegrityError: insert or update on table "features_featurestate" violates foreign key constraint "features_featurestat_feature_segment_id_547d5f48_fk_features_"
DETAIL: Key (feature_segment_id)=(37855) is not present in table "features_featuresegment".

(16 additional frame(s) were not displayed)
...
File "environments/views.py", line 142, in clone
clone = serializer.save(source_env=self.get_object())
File "environments/serializers.py", line 121, in create
clone = source_env.clone(name)
File "environments/models.py", line 171, in clone
feature_state.clone(clone, live_from=feature_state.live_from)
File "features/models.py", line 574, in clone
clone.save()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.