migrate-apim: a policy in a fragment is attributed to no API, strands its target object, and aborts the policies phase
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 18
- フォーク
- 9
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 23
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure/aigateway のほかの issue
-
How do I use the AI Gateway to route to ADO Remote MCP Server?対応中かも @santiagxf が今日担当しました。 オープンquestion
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
Azure/aigateway#72 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Playground testing to external claude enterprise fails from AI Gateway対応中かも @santiagxf が今日担当しました。 オープンinvestigate
難易度 3/5 1〜2日 初心者へのやさしさ 53/100
Azure/aigateway#71 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
migrate-apim: partialWhen conditions are declared in the schema and implemented in the planner, and nothing checks the two agree対応中かも @santiagxf が今日担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
Azure/aigateway の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
qboson/kaiwu-pytorch-plugin#2308 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
NL-BioImaging/biomero-converter#43 ·
メンテナーはふだん 1 日以内に返信
-
Name the maintainers in CODEOWNERS対応中かも @TorecLuik が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
NL-BioImaging/BIOMERO.shallower#41 ·
メンテナーはふだん 1 日以内に返信
-
soup drift-alarm drops malformed and unrecognised live rows without saying so, then reports OK on the rows that are left対応中かも @abdulwaarith0 が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
MakazhanAlpamys/Soup#3665 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
roadmap/v1.3.0 scope/entitlement type/improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
databrickslabs/ontos#1778 ·
メンテナーはふだん 2 日以内に返信