Skip to content

Conversation

junaed-optimizely
Copy link
Contributor

Summary

This pull request adds a new validation for null flag keys in the decision logic, ensuring that passing a null flag key to the Decide method returns a proper error decision. It also introduces a corresponding unit test to verify this behavior.

Error handling improvements:

  • Added a check in Optimizely.cs to return an error decision if the flag key passed to Decide is null, using a specific error message (FLAG_KEY_INVALID).

Testing enhancements:

  • Added a new test, DecideNullFlagKey, in OptimizelyUserContextTest.cs to verify that passing a null flag key returns the expected error decision.

Issues

FSSDK-11837

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request improves error handling in the Optimizely SDK by adding validation for null flag keys in the Decide method. When a null flag key is passed, the method now returns a proper error decision with a specific error message instead of potentially causing downstream issues.

  • Added null check validation in the Decide method to return an error decision for null flag keys
  • Added unit test to verify the new null flag key validation behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
OptimizelySDK/Optimizely.cs Added null check for flag key parameter in Decide method with proper error handling
OptimizelySDK.Tests/OptimizelyUserContextTest.cs Added unit test to verify null flag key returns expected error decision

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@mikechu-optimizely mikechu-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the check for key equals null check and the supporting unit test.

@junaed-optimizely junaed-optimizely merged commit 2d23fe1 into master Sep 4, 2025
11 checks passed
@junaed-optimizely junaed-optimizely deleted the junaed/fssdk-11837-key-null-decide branch September 4, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants