-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Handle null, empty, or whitespaces for RolloutId #304
Conversation
Includes unit test covering existing logic
Grrr we have to put up with this until 2029 unless we check w/ our clients to see if we can remove it.
@msohailhussain I don't seem to have access to edit the CI GitHub Action where I can figure out how to correct this error.
I see that it's not a required Check, but I like all ✔️ 🤷 |
I need to get those pre-commit hooks running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address
[Test] | ||
public void TestRolloutWithEmptyStringRolloutIdFromConfigFile() | ||
{ | ||
var projectConfig = DatafileProjectConfig.Create(TestData.EmptyRolloutDatafile, new NoOpLogger(), new NoOpErrorHandler()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of NoOpErrorHandler, can you please use ErrorHandler with the the flag, that exception should be raised when error is raised.
|
||
var rollout = projectConfig.GetRolloutFromId(featureFlag.RolloutId); | ||
|
||
// OptlyConfig.OptimizelyConfigService.GetDeliveryRules L362 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment specifically Line number, that can be change in future.
|
||
var rollout = Config.GetRolloutFromId(rolloutId); | ||
|
||
// OptlyConfig.OptimizelyConfigService.GetDeliveryRules L362 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
|
||
var rollout = Config.GetRolloutFromId(rolloutId); | ||
|
||
// OptlyConfig.OptimizelyConfigService.GetDeliveryRules L362 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -13,6 +13,7 @@ | |||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String> | |||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String> | |||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EXPR_MEMBER_ARRANGEMENT/@EntryValue">False</s:Boolean> | |||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_INITIALIZER_ARRANGEMENT/@EntryValue">False</s:Boolean> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is causing linter to cause errors. not sure.
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If .DotSettings
is causing problems should I add JetBrains to .gitignore
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not problematic, just end of line is better to have at the end of file.
@@ -636,6 +636,11 @@ public Variation GetFlagVariationByKey(string flagKey, string variationKey) | |||
/// <returns>Rollout Entity corresponding to the rollout ID or a dummy entity if ID is invalid</returns> | |||
public Rollout GetRolloutFromId(string rolloutId) | |||
{ | |||
if (string.IsNullOrEmpty(rolloutId.Trim())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will cause exception in case rolloutId is missing and eventually null
is passed. Check this method
string.IsNullOrWhiteSpace
@mikechu-optimizely in unit tests add one more case for passing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
rolloutId
in datafileAn empty string rolloutId should be ignored and not raise and exception
Test plan
Unit test added to OptimizelySDK.Tests/ProjectConfigTest.cs
Issues