[OFREP] Should variant and reason tolerate what the spec makes optional?
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
Línea de trabajo
Comienza en ofrep/init.py, en la construcción de FlagResolutionDetails, y lee el código circundante de mapeo de respuestas. Comprueba las definiciones de campos opcionales en types.md y los requisitos de los proveedores de OFREP a los que se hace referencia. Se considera terminado cuando las respuestas sin variant y las respuestas con cadenas de reason no estándar se manejan sin un KeyError no intencionado, con cobertura para ambos casos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Two questions about the same three lines in ofrep/__init__.py, both about optional fields being indexed unconditionally. Asking rather than reporting, in case either is a deliberate strictness choice.
value = data.get("value", default_value) # tolerant
_typecheck_flag_value(value, flag_type)
return FlagResolutionDetails(
value=value,
reason=Reason[data["reason"]], # (2)
variant=data["variant"], # (1)
flag_metadata=data.get("metadata", {}),
)
value is read with a default; the two below it are not. That asymmetry is what makes me think the others might be oversights rather than intent.
1. variant is optional, but indexed
types.md types it variant (string, optional), and OFREP's evaluationSuccess requires only key and reason.
Observed against flagd-testbed:v3.8.0:
$ curl -s -X POST localhost:8016/ofrep/v1/evaluate/flags/disabled-boolean-flag -d '{"context":{}}'
{"key":"disabled-boolean-flag","reason":"DISABLED","metadata":{}} HTTP 200
KeyError: 'variant', surfacing to the application as GENERAL. Note value is already handled correctly for this response — OFREP's codeDefaultFlag schema omits value on purpose ("The provider must use the code default value when processing this response"), and data.get("value", default_value) does exactly that. So the response is understood apart from the variant.
This is not specific to disabled flags: any response omitting variant would do it.
Question: should this be data.get("variant"), or is there a reason to require the field?
2. Reason[...] is an enum lookup by name
Reason[data["reason"]] raises KeyError for any reason outside the nine members of Python's Reason enum. But Requirement 2.2.5 permits a provider to populate reason with one of the listed values "or some other string indicating the semantic reason for the returned flag value", and types.md adds:
The
reasonshould not be limited to the reasons enumerated above. It can be any of the pre-defined reasons, or any string value.
The Python SDK models this correctly — FlagEvaluationDetails.reason is typed str | Reason | None. So an OFREP server returning a vendor-specific reason string appears to crash this provider on a response the specification explicitly allows.
I have not observed this one in the wild — flagd only returns standard reasons — so it is inference from the code, not a reproduction. Flagging it because it is the same line and the same class of thing.
Question: should the reason fall back to the raw string when it is not a known member, rather than raising?
Context
Found while building the cross-language provider conformance suite proposed in open-feature/spec#417. A new gated @disabled-flags capability exposed (1); (2) came from reading the surrounding lines. For calibration, the Go and JavaScript OFREP providers pass the same scenarios, so this does not look like a limitation of OFREP.
Happy to be told either of these is intended.
- Lenguaje dominante
- Python
- Estrellas
- 27
- Forks
- 33
- Merge medio
- 5 h
- PR fusionados (30 d)
- 10
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de open-feature/python-sdk-contrib
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
UnleashProvider.track has the wrong signature: client.track raises TypeError instead of no-op Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
open-feature/python-sdk-contrib#417 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Todos los issues de open-feature/python-sdk-contrib
Issues similares
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Abiertoarea: harness bug status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Human-Agent-Society/reef#625 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
learningequality/kolibri#15351 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Name consistency Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eellak/triplestore#65 · 1 comentario ·