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

Feature flags not working when evaluated outside the context of a request #3775

Open
blkt opened this issue Jul 3, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working P2 Nice to fix: non-critical items that should be evaluated and planned during issue triage

Comments

@blkt
Copy link
Contributor

blkt commented Jul 3, 2024

Describe the issue

Feature flags evaluated outside the context of a request don't populate EvaluationContext correctly.

An example of where this bug happens is here, which is the code path executed during the evaluation of a profile rule. That code path goes on running this line which eventually runs jwt.GetUserSubjectFromContext(ctx) which leads to empty string being returned as targetingKey (here).

This is an example stack trace that leads to error openfeature: TARGETING_KEY_MISSING: no targetingKey provided in the evaluation context

 0  0x0000000105e54b80 in github.com/stacklok/minder/internal/auth.GetUserSubjectFromContext
    at ./internal/auth/jwtauth.go:119
 1  0x000000010602c098 in github.com/stacklok/minder/internal/flags.fromContext
    at ./internal/flags/flags.go:42
 2  0x000000010602c2c4 in github.com/stacklok/minder/internal/flags.Bool
    at ./internal/flags/flags.go:52
 3  0x00000001065fb414 in github.com/stacklok/minder/internal/engine.(*Executor).createOrUpdateEvalStatus
    at ./internal/engine/eval_status.go:204
 4  0x00000001065fd8d0 in github.com/stacklok/minder/internal/engine.(*Executor).evalEntityEvent.func1.1
    at ./internal/engine/executor.go:226
 5  0x000000010608ddc4 in github.com/stacklok/minder/internal/profiles.TraverseRules
    at ./internal/profiles/util.go:165
 6  0x00000001065fd32c in github.com/stacklok/minder/internal/engine.(*Executor).evalEntityEvent.func1
    at ./internal/engine/executor.go:203
 7  0x00000001065fdeec in github.com/stacklok/minder/internal/engine.(*Executor).forProjectsInHierarchy
    at ./internal/engine/executor.go:266
 8  0x00000001065fce24 in github.com/stacklok/minder/internal/engine.(*Executor).evalEntityEvent
    at ./internal/engine/executor.go:194
 9  0x00000001065fc670 in github.com/stacklok/minder/internal/engine.(*Executor).HandleEntityEvent.func1
    at ./internal/engine/executor.go:142

To Reproduce

  • add this to flags-config.yaml
eval_history:
  variations:
    enabled: true
    disabled: false
  defaultRule:
    variation: enabled
  • trigger some rule evaluation
  • connect to postgresql (e.g. psql minder)
  • run select * from evaluation_statuses

What version are you using?

minder-0.20240703.2465_ref.924bd1a

@blkt blkt added the bug Something isn't working label Jul 3, 2024
@blkt blkt changed the title EvaluationContext missing when feature flags evaluated outside the context of a request Feature flags not working when evaluated outside the context of a request Jul 3, 2024
blkt added a commit that referenced this issue Jul 4, 2024
This was necessary for local testing because of the following issue.
#3775
blkt added a commit that referenced this issue Jul 4, 2024
This was necessary for local testing because of the following issue.
#3775
blkt added a commit that referenced this issue Jul 5, 2024
This was necessary for local testing because of the following issue.
#3775
@dmjb dmjb self-assigned this Jul 9, 2024
blkt added a commit that referenced this issue Jul 10, 2024
This was necessary for local testing because of the following issue.
#3775
@evankanderson evankanderson added the P2 Nice to fix: non-critical items that should be evaluated and planned during issue triage label Sep 10, 2024
@eleftherias eleftherias assigned evankanderson and unassigned dmjb Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Nice to fix: non-critical items that should be evaluated and planned during issue triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants