Skip to content
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

currentTime strategy constraint doesn't work #245

Closed
tlevesque-ueat opened this issue Oct 23, 2024 · 4 comments · Fixed by #246
Closed

currentTime strategy constraint doesn't work #245

tlevesque-ueat opened this issue Oct 23, 2024 · 4 comments · Fixed by #246
Assignees

Comments

@tlevesque-ueat
Copy link
Contributor

Describe the bug
If I create a strategy with a DATE_AFTER constraint on currentTime, with a date in the past, the feature flag is always considered disabled.
The same feature flag works fine on the frontend with unleash-proxy-client-js.

To Reproduce
Steps to reproduce the behavior:

  1. Create a feature flag with a gradual rollout strategy with 100% rollout
  2. Add a constraint on currentTime with DATE_AFTER and a date in the past
  3. In the app, call IUnleash.IsEnabled("MyFeatureFlag")
  4. It always returns false, whether the current date is before or after the specified date
  5. Remove the currentTime constraint
  6. Now IUnleash.IsEnabled("MyFeatureFlag") returns true

Expected behavior
IUnleash.IsEnabled("MyFeatureFlag") should return true if the current date is after the specified date

Screenshots
image

Desktop (please complete the following information):

  • OS: Ubuntu (deployed application), Windows (for local development)
  • Browser: irrelevant (server application)
  • Version: 4.1.13
@tlevesque-ueat
Copy link
Contributor Author

I think the problem is here:

contextDate = context.CurrentTime;
if (!contextDate.HasValue)
return false;

If context.CurrentTime is not set, it should use the current time. That's what the documentation says anyway:
image

@tlevesque-ueat
Copy link
Contributor Author

tlevesque-ueat commented Oct 23, 2024

In fact, shouldn't it use context.CurrentTime only if constraint.ContextName is "currentTime"?
It seems a little strange that it would fall back to context.CurrentTime if I specified "myCustomDate" as the context name...

@tlevesque-ueat
Copy link
Contributor Author

I submitted a PR
#246

@daveleek
Copy link
Collaborator

thank you for raising this and for providing a clear bug report + a PR @tlevesque-ueat! We'll have a look and get back to you!

@github-project-automation github-project-automation bot moved this from Investigating to Done in Issues and PRs Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
2 participants