ff4j / ff4j-spring-boot-starter-parent

A spring boot starter for FF4J (Feature Flipping For Java)
Apache License 2.0
32 stars 26 forks source link

Feature flag is not created when check endpoint is called even with autoCreate(true) #355

Closed tiagozc closed 1 year ago

tiagozc commented 1 year ago

Describe the bug I'm not sure whether this is a bug or a design decision, but when the FF4J is set up with autoCreate(true) and you request the /check endpoint for an array of feature flags it does not auto create them. The code actually it's quite explicitly asserting that the feature flag must exist otherwise throwing an exception. But the FF4J core check() method (not the endpoint) does similar thing, but auto creates the feature flag if that is enabled.

To Reproduce Steps to reproduce the behavior:

  1. Configure FF4J with autoCreate(true)
  2. Call the /check endpoint with an inexistent feature flag

Expected behavior The feature flag gets auto created.

paul58914080 commented 1 year ago

It is per design. @clun any thoughts ?

clun commented 1 year ago

As of today the creation of the feature is triggered on the enable() and not check(). It would make sense to have it in the check as well i guess, it used to be the case.

https://github.com/ff4j/ff4j/blob/main/ff4j-core/src/main/java/org/ff4j/FF4j.java#L345

tiagozc commented 1 year ago

@clun it looks like it also creates on check()... check() calls getFeature(), which then creates the feature flag also in case autoCreate is enabled

paul58914080 commented 1 year ago

@tiagozc, hoping your question is answered. If not, please feel free to re-open