Skip to content

Commit 4a83292

Browse files
authored
fix: handle null django_id in identity overrides (#122)
1 parent e3b484b commit 4a83292

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Flagsmith.Client.Test/Fixtures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ internal class Fixtures
8484
'featurestate_uuid': '1bddb9a5-7e59-42c6-9be9-625fa369749f',
8585
'feature_state_value': 'some-overridden-value',
8686
'enabled': false,
87+
'django_id': null,
8788
'environment': 1,
8889
'identity': null,
8990
'feature_segment': null

Flagsmith.Engine/Feature/Models/FeatureStateModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class FeatureStateModel
2222
[JsonProperty(PropertyName = "multivariate_feature_state_values")]
2323
public List<MultivariateFeatureStateValueModel> MultivariateFeatureStateValues { get; set; }
2424
[JsonProperty(PropertyName = "django_id")]
25-
public int DjangoId { get; set; }
25+
public int? DjangoId { get; set; }
2626
public string FeatureStateUUID { get; set; } = new Guid().ToString();
2727
[JsonProperty(PropertyName = "feature_segment")]
2828
public FeatureSegmentModel FeatureSegment { get; set; } = null;
@@ -33,7 +33,7 @@ public object GetMultivariateValue(string identityId)
3333
{
3434
var percentageValue = Hashing.GetHashedPercentageForObjectIds(new List<string>
3535
{
36-
DjangoId != 0 ? DjangoId.ToString() : FeatureStateUUID,
36+
DjangoId != null ? DjangoId.ToString() : FeatureStateUUID,
3737
identityId.ToString()
3838
});
3939
var startPercentage = 0.0;

Flagsmith.FlagsmithClient/Flagsmith.FlagsmithClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
88
<PackageId>Flagsmith</PackageId>
99
<Title>Flagsmith</Title>
10-
<Version>5.4.2</Version>
10+
<Version>5.4.3</Version>
1111
<Authors>flagsmith</Authors>
1212
<Company>Flagsmith</Company>
1313
<PackageDescription>Client SDK for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://flagsmith.com/</PackageDescription>

0 commit comments

Comments
 (0)