Distinguish unresolved from resolved-empty required resources
還沒有人認領這個 Issue。
評估
研究方向
先閱讀 request.get_required_resource 和 get_required_resources API 及其 docstring,接著比較相應的 require_schema/get_required_schema 行為。定義支援的 unresolved、absent 和 present 情況,並透過測試確認所選擇的 API 形式;完成的標準是呼叫端無需重複 membership check 即可區分這些狀態。
由索引模型根據 Issue 內容生成。
描述
What problem are you facing?
request.get_required_resource (and get_required_resources) returns None/[] in two semantically different cases: the requirement hasn't been resolved by Crossplane yet, and the requirement resolved but matched nothing. The only way to tell them apart is to also check name in req.required_resources, which the get_required_resources docstring documents as a caveat the caller must handle by hand.
This distinction matters whenever a function gates on an external resource. "Not resolved yet" is transient — wait and let Crossplane re-call. "Resolved, matched nothing" is a real state — the resource was deleted, or its reference is a typo — and usually wants a different response (e.g. a warning, or holding steady rather than waiting). Functions end up reimplementing the same in-then-get dance. We hit it twice in one project: once gating a hydration Job on an auth Secret, and once gating replica placement on a referenced cache being resolvable.
How could this Function help solve your problem?
A small helper that classifies a required resource into the three states, so callers don't each re-derive it from the in check. Roughly:
class Resolution(enum.Enum):
UNRESOLVED = "unresolved" # Crossplane hasn't fetched it yet (key absent)
ABSENT = "absent" # resolved, but nothing matched
PRESENT = "present" # resolved and found
def resolve_required(req, name) -> tuple[Resolution, dict | None]: ...
A list variant (and possibly the same for require_schema/get_required_schema, which has the analogous distinction) would round it out. Naming/placement and whether this is an enum vs. a small result type are open — happy to send a PR once there's a preferred shape.
- 主要語言
- Python
- 星號
- 12
- 分支
- 15
- 平均合併
- 1 天 6 小時
- 30 天內合併 PR
- 10
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
crossplane/function-sdk-python 的其他 Issue
-
enhancement
難度 5/5 一週以上 新手友好度 35/100
crossplane/function-sdk-python#199 · 4 則留言 · 3 個 reaction ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
crossplane/function-sdk-python#129 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 10/100
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
crossplane/function-sdk-python#5 · 1 則留言 ·
查看 crossplane/function-sdk-python 的全部 Issue
相似的 Issue
-
area: harness bug status: needs-triage
難度 2/5 1-3 小時 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 1/5 1 小時以內 新手友好度 80/100
learningequality/kolibri#15351 · 2 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
Name consistency 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
eellak/triplestore#65 · 1 則留言 ·