Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,11 @@ def _convert_context(
if evaluation_context:
try:
s["targetingKey"] = evaluation_context.targeting_key
s.update(evaluation_context.attributes) # type: ignore[arg-type]
s.update(
typing.cast(
"typing.Mapping[str, typing.Any]", evaluation_context.attributes
)
)
except ValueError as exc:
message = (
"could not serialize evaluation context to google.protobuf.Struct"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import time
import typing

Expand Down Expand Up @@ -31,9 +33,11 @@ def targeting(
if not isinstance(targeting, dict):
raise ParseError(f"Invalid 'targeting' value in flag: {targeting}")

json_logic_context = evaluation_context.attributes if evaluation_context else {}
json_logic_context["$flagd"] = {"flagKey": key, "timestamp": int(time.time())} # type: ignore[index]
json_logic_context["targetingKey"] = ( # type: ignore[index]
json_logic_context: dict[str, typing.Any] = (
dict(evaluation_context.attributes) if evaluation_context else {}
)
json_logic_context["$flagd"] = {"flagKey": key, "timestamp": int(time.time())}
json_logic_context["targetingKey"] = (
evaluation_context.targeting_key if evaluation_context else None
)
return jsonLogic(targeting, json_logic_context, OPERATORS)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from math import floor

import pytest
from json_logic import builtins, jsonLogic # type: ignore[import-untyped]
from json_logic import builtins, jsonLogic

from openfeature.contrib.provider.flagd.resolvers.process.custom_ops import (
ends_with,
Expand Down