Skip to content

Commit 1b026df

Browse files
committed
fix: Nullcheck Migration Values before Porting
While migrating, do some nullchecking to ensure that values are present before trying to import them.
1 parent c7b4dd3 commit 1b026df

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

com.playeveryware.eos/Runtime/Core/Config/ProductConfig.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ private void MigrateProductNameVersionAndId(PreviousEOSConfig config)
141141
ProductName = config.productName;
142142
ProductVersion = config.productVersion;
143143

144-
if (!Guid.TryParse(config.productID, out ProductId))
144+
// Attempt to parse the productID, and log a message if it cannot be parsed
145+
// Do not log a message if the productID is empty, and could not possibly migrate
146+
if (!string.IsNullOrWhiteSpace(config.productID) && !Guid.TryParse(config.productID, out ProductId))
145147
{
146148
Debug.LogWarning("Could not parse product ID.");
147149
}
@@ -151,13 +153,24 @@ private void MigrateClientCredentials(PreviousEOSConfig config)
151153
{
152154
#if !EOS_DISABLE
153155
// Import the old config client stuff
154-
Clients.Add(new EOSClientCredentials(config.clientID, config.clientSecret,
155-
config.encryptionKey));
156+
// Some amount of these values should be provided, though encryptionKey is optional
157+
if (!string.IsNullOrWhiteSpace(config.clientID) && !string.IsNullOrWhiteSpace(config.clientSecret))
158+
{
159+
Clients.Add(new EOSClientCredentials(config.clientID, config.clientSecret,
160+
config.encryptionKey));
161+
}
156162
#endif
157163
}
158164

159165
private void MigrateSandboxAndDeployment(PreviousEOSConfig config)
160166
{
167+
// Check to see if the sandbox and deployment id were configured in the previous config
168+
if (string.IsNullOrWhiteSpace(config.sandboxID) || string.IsNullOrEmpty(config.deploymentID))
169+
{
170+
// One of them is empty, we can't possibly add this deployment
171+
return;
172+
}
173+
161174
// Import explicitly set sandbox and deployment
162175
SandboxId sandboxId = new()
163176
{
@@ -181,6 +194,13 @@ private void MigrateSandboxAndDeployment(PreviousEOSConfig config)
181194

182195
private void MigrateSandboxAndDeploymentOverrides(PreviousEOSConfig config)
183196
{
197+
// If the sandboxDeploymentOverrides didn't parse, they were likely missing
198+
// Only migrate values if they are present
199+
if (config.sandboxDeploymentOverrides == null)
200+
{
201+
return;
202+
}
203+
184204
// Import each of the overrides
185205
foreach (var overrideValues in config.sandboxDeploymentOverrides)
186206
{

0 commit comments

Comments
 (0)