migrate-apim: a policy in a fragment is attributed to no API, strands its target object, and aborts the policies phase
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Read tools/migrate-apim/migrate_apim/plan.py around _apis_in_scope() and _per_model_objects(), then trace how fragmentRefs or policyRefs.fragments are recorded in collect.py. Start with tests/test_plan.py and add coverage for a fragment included by APIs that register models. Done means the fragment policy is attributed to its including APIs and no longer strands an object or stops the policies phase.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
_policies() iterates inventory["policies"], which holds one document per scope — and a policy fragment is one of those documents, with scope.level == "fragment". Its elements are therefore classified once, as the fragment, and never attributed to the APIs that include it.
_apis_in_scope() (tools/migrate-apim/migrate_apim/plan.py:1387-1406) handles global/service/None, api, workspace, and product, and returns set() for everything else. fragment falls into that final return set(), so _registrations_in_scope() finds no models and _per_model_objects() emits a stranded object (plan.py:1277-1290):
configurationComplete: false
incompleteReason: "No model registration in this plan falls under fragment '<name>',
so there is nothing to carry the policy."
At apply time, _model_policy_set() raises ApplyError on the missing modelName (apply.py:1021-1025), _run_object turns that into status: failed, and run_phase breaks out of the step loop (apply.py:581-583). Every remaining policy step in that phase is skipped.
Impact
Factoring one llm-token-limit into a shared fragment and including it from several APIs is a normal APIM pattern — arguably the recommended one. Today it classifies as native, appears in the plan as ready, provisions nothing, and stops the policies phase.
The failure's remedy — "re-plan from a current inventory" — cannot fix it: a re-plan produces the same stranded object.
The incompleteReason is also wrong in this case, as distinct from merely unhelpful. For a fragment there is something to carry the policy; the planner just has no path from the fragment to the including APIs.
Contract mismatch
capabilities/rules.json gives policyFragments the verdict handled with the rationale "Resolved into the including policy before mapping."
That is not what happens in _policies(). The routine that does resolve fragments — _flatten() at collect.py:1636-1680 — builds a separate flattened view used for backend-auth determination, and never feeds the planner. The stated contract and the behavior disagree.
Scope of the defect
Baseline policies are unaffected: _baseline_object() doesn't consult API scope, so a fragment-scoped rate-limit-by-key or ip-filter still collapses into the gateway-wide baseline correctly. Only per-model targets (capabilityId == "model.policy") strand.
Suggested fix
Expand fragment-document elements into one batch member per including scope, using the fragmentRefs / policyRefs.fragments links collect already records (collect.py:2248), so a fragment included by four APIs contributes four members and the existing per-model expansion and batchOn dedup handle the rest.
A narrower alternative is to teach _apis_in_scope() to resolve fragment to the union of APIs whose documents reference it.
Test gap
tests/test_plan.py:1025 (test_a_scope_with_no_models_says_so_instead_of_vanishing) covers the stranded path for an api scope that registers no model — a genuinely empty scope. The fragment case is structurally different, because the including APIs do register models, and is untested.
Found while documenting the migration flow. Derived from reading the source and the existing tests; not reproduced against a live APIM instance.
- Ngôn ngữ chính
- Python
- Star
- 18
- Fork
- 9
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/aigateway
-
How do I use the AI Gateway to route to ADO Remote MCP Server?Có thể đã có người làm @santiagxf đã nhận hôm nay. Đang mởquestion
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Azure/aigateway#72 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Playground testing to external claude enterprise fails from AI GatewayCó thể đã có người làm @santiagxf đã nhận hôm nay. Đang mởinvestigate
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 53/100
Azure/aigateway#71 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
migrate-apim: partialWhen conditions are declared in the schema and implemented in the planner, and nothing checks the two agreeCó thể đã có người làm @santiagxf đã nhận hôm nay. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Azure/aigateway
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
qboson/kaiwu-pytorch-plugin#2308 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
NL-BioImaging/biomero-converter#43 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Name the maintainers in CODEOWNERSCó thể đã có người làm @TorecLuik đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
NL-BioImaging/BIOMERO.shallower#41 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
soup drift-alarm drops malformed and unrecognised live rows without saying so, then reports OK on the rows that are leftCó thể đã có người làm @abdulwaarith0 đã nhận hôm nay. Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
MakazhanAlpamys/Soup#3665 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
roadmap/v1.3.0 scope/entitlement type/improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
databrickslabs/ontos#1778 ·
Maintainer thường phản hồi trong vòng 2 ngày