Is InMemoryFlag.state intended to be honoured? DISABLED is never read
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 openfeature/provider/in_memory_provider.py 中的 InMemoryFlag.state 和 resolve() 開始,接著比較 issue 中描述的、文件所述的跨語言停用 flag 行為。確認 Python 是否應遵循 DISABLED,或僅為了相容性而保留該欄位。完成的標準是:已決定並記錄預期行為;如果 maintainers 選擇進行變更,則已更新相關的記憶體內 provider 行為或測試。
由索引模型根據 Issue 內容生成。
描述
InMemoryFlag declares a state field with an ENABLED/DISABLED enum, and as far as I can tell nothing ever reads it. Asking because "the field is there for API compatibility and honouring it was never promised" is a perfectly good answer, and I would rather have it recorded than assume a bug.
What I see
openfeature/provider/in_memory_provider.py:
class InMemoryFlag(typing.Generic[T_co]):
class State(StrEnum):
ENABLED = "ENABLED"
DISABLED = "DISABLED"
default_variant: str
variants: dict[str, T_co]
flag_metadata: FlagMetadata = field(default_factory=dict)
state: State = State.ENABLED # line 47
...
def resolve(self, evaluation_context):
if self.context_evaluator:
return self.context_evaluator(self, evaluation_context or EvaluationContext())
return FlagResolutionDetails(
value=self.variants[self.default_variant],
reason=Reason.STATIC,
variant=self.default_variant,
flag_metadata=self.flag_metadata,
)
grep -n state in_memory_provider.py returns exactly one line — the declaration above. State.DISABLED does not appear anywhere else in the package.
So a flag constructed with state=State.DISABLED resolves to its own defaultVariant with reason STATIC, as though it were enabled.
Why I think it may be worth changing
For comparison, across the other in-memory reference providers:
| SDK | field | behaviour on a disabled flag |
|---|---|---|
| JavaScript | disabled: boolean |
caller's default, reason: DISABLED, no error code |
| Java | disabled (isDisabled) |
caller's default, reason: DISABLED, no error code |
| Go | State enum |
caller's default + reason: DISABLED, but also a GENERAL error — reported as go-sdk#552, fixed by #574 |
| Python | state enum |
resolves as if enabled |
Two of the four substitute the caller's default with reason: DISABLED and no error; Go agreed that was the right answer when it was raised. That is convention rather than specification — I could find no numbered requirement saying what a provider owes a disabled flag — so this is not a conformance claim, just a consistency observation.
Also worth noting the two shapes in the ecosystem: state: ENABLED|DISABLED in Go, Python and flagd's flag format, versus disabled: boolean in JavaScript, Java and Appendix B's test-flags.json. Not something to fix here, but it is why the field probably exists in this shape.
Questions
- Is
stateintended to be honoured byresolve(), or is it carried for configuration compatibility only? - If it should be honoured — is the intended behaviour the caller's default with
reason: DISABLEDand no error code, matching JavaScript and Java? - Would you rather the field were removed than implemented, if honouring it is not wanted? A declared field that is never read seems the more surprising of the two states.
Context
Found while building the cross-language provider conformance suite proposed in open-feature/spec#417. A new gated @disabled-flags capability is left undeclared for the Python in-memory suites on the strength of this, and the four scenarios skip rather than fail — so nothing is blocked. Recording the question so the reason for that gate is not just in my head.
- 主要語言
- Python
- 星號
- 112
- 分支
- 46
- 平均合併
- 22 小時 52 分鐘
- 30 天內合併 PR
- 22
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
open-feature/python-sdk 的其他 Issue
-
[BUG] before hooks do not receive the evaluation context returned by earlier before hooks可能已有人在做 @Ritinpaul 於 11 天前認領。 未關閉bug
難度 3/5 1-2 天 新手友好度 78/100
open-feature/python-sdk#628 ·
維護者通常 1 天內回覆
-
v0.9.0
難度 5/5 一週以上 新手友好度 25/100
open-feature/python-sdk#618 ·
維護者通常 1 天內回覆
-
Supply the bound domain to provider initialization可能已有人在做 @jonathannorris 於 107 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 55/100
open-feature/python-sdk#615 ·
維護者通常 1 天內回覆
-
Support isolated API instances可能已有人在做 @marcozabel 於 178 天前認領。 未關閉
open-feature/python-sdk#584 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[Multi-provider] Gaps identified relative to js-sdk reference implementation可能已有人在做 @jonathannorris 於 215 天前認領。 未關閉multi-provider
難度 5/5 一週以上 新手友好度 25/100
open-feature/python-sdk#568 ·
維護者通常 1 天內回覆
查看 open-feature/python-sdk 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 77/100
TomerAberbach/profiler-md#733 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
its-me-prash/vwgroup-connect-ha#1858 ·
維護者通常 1 天內回覆
-
area: client bug
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
leikoilja/ha-google-home#1107 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
Graphify-Labs/graphify#4524 · 1 則留言 ·
維護者通常 1 天內回覆