flagr icon indicating copy to clipboard operation
flagr copied to clipboard

Add entityId to EntityContext for evaluating constraints

Open sesquipedalian-dev opened this issue 4 years ago • 2 comments

In rolling out a recent feature, I had a case where I wanted to white / black list particular entity IDs from being distributed to the new feature. It would be handy for Flagr to include the entity ID in the entity context when evaluating constraints, to enable this. I'm unsure how the property should be named; 'id', 'entityId', 'entity_id', etc.

Expected Behavior

You should be able to set a constraint that evaluates the entity ID of the flagr evaluate request.

Current Behavior

Flagr only includes properties explicitly included in the entityContext parameter of eval requests.

Possible Solution

Around https://github.com/checkr/flagr/blob/master/pkg/handler/eval.go#L239, before sending the entity context, add an 'id' field containing the value of the entity ID passed in.

sesquipedalian-dev avatar Feb 17 '20 16:02 sesquipedalian-dev

How about @entityID? We can even extend this convention to something else that can be derived from the request. The camel case naming is from https://checkr.github.io/flagr/api_docs/#tag/evaluation

@entityID
@entityType
@timestamp
...

Some open questions to consider for records logging:

  • Do we include these as entityContext for flagr records logging?
  • And since we are already logging these, which means simply putting these into entityContext will have duplicate logging of the evaluation result.

zhouzhuojie avatar Feb 17 '20 17:02 zhouzhuojie

I like the idea of @<field>, and including the other fields as well for more flexibility!

sesquipedalian-dev avatar Feb 17 '20 17:02 sesquipedalian-dev

Stale issue message

github-actions[bot] avatar Aug 26 '22 21:08 github-actions[bot]