Skip to content

Commit f27ee70

Browse files
Cherry-Pick Bug Fix for 1.5 Release (#2718)
## Why make this change? When we create the entity cache options, we start with a new object and then later set the values for the fields. Because of this, the `bool` `UserProvidedTtlOptions` must explicitly be set when we later set these values or it will forever remain `false`. When it is false it is not written back out into the configuration file. ## What is this change? Fixes bug found in release candidate for 1.5 Cherry-picked PR: - #2717 ## How was this tested? ## Sample Request(s) Co-authored-by: aaronburtle <[email protected]>
1 parent 6ad5ccb commit f27ee70

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Cli/Utils.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ public static EntityGraphQLOptions ConstructGraphQLTypeDetails(string? graphQL,
843843

844844
EntityCacheOptions cacheOptions = new();
845845
bool isEnabled = false;
846+
bool isCacheTtlUserProvided = false;
846847
int ttl = EntityCacheOptions.DEFAULT_TTL_SECONDS;
847848

848849
if (cacheEnabled is not null && !bool.TryParse(cacheEnabled, out isEnabled))
@@ -855,20 +856,26 @@ public static EntityGraphQLOptions ConstructGraphQLTypeDetails(string? graphQL,
855856
_logger.LogError("Invalid format for --cache.ttl. Accepted values are any non-negative integer.");
856857
}
857858

859+
// This is needed so the cacheTtl is correctly written to config.
860+
if (cacheTtl is not null)
861+
{
862+
isCacheTtlUserProvided = true;
863+
}
864+
858865
// Both cacheEnabled and cacheTtl can not be null here, so if either one
859866
// is, the other is not, and we return the cacheOptions with just that other
860867
// value.
861868
if (cacheEnabled is null)
862869
{
863-
return cacheOptions with { TtlSeconds = ttl };
870+
return cacheOptions with { TtlSeconds = ttl, UserProvidedTtlOptions = isCacheTtlUserProvided };
864871
}
865872

866873
if (cacheTtl is null)
867874
{
868875
return cacheOptions with { Enabled = isEnabled };
869876
}
870877

871-
return cacheOptions with { Enabled = isEnabled, TtlSeconds = ttl };
878+
return cacheOptions with { Enabled = isEnabled, TtlSeconds = ttl, UserProvidedTtlOptions = isCacheTtlUserProvided };
872879
}
873880

874881
/// <summary>

0 commit comments

Comments
 (0)