migrate-apim: handled elements are skipped before expression analysis, so policy-driven backend selection leaves no trace in the plan

Cerrado
#59 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #66 de @santiagxf — cerrado sin fusionar
  • #67 de @santiagxf — cerrado sin fusionar

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
backend, cloud

Línea de trabajo

Start in plan.py at _policies() around line 879 and trace how policy elements reach _apply_partial_when(); then read the element-name rules in capability.py around lines 185–197. Check the statement-wrapper handling around plan.py line 1842 and compare how handled managed identity is represented around lines 290, 346, and 1134. Done means conditional or expression-driven set-backend-service routing is visible in the plan without changing sound handled cases.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Summary

_policies() drops handled and notApplicable elements before any further inspection (plan.py:879):

if not rule or rule["verdict"] in {"notApplicable", "handled"}:
    continue

This happens before _apply_partial_when() on the next line, and element-name rules win over the hasExpression fallback by design (capability.py:185-197). The combination means set-backend-service — verdict handled, rationale "Backend selection becomes the alias backend pool" — is skipped regardless of what it actually does:

  • <set-backend-service backend-id="@(expression)" />, an arbitrary C# routing decision.
  • set-backend-service nested under choose/when, which _STATEMENT_WRAPPERS (plan.py:1842) correctly treats as a statement, so the element is classified and then discarded.

The alias backend pool is built from the APIM backend pool, which carries none of that conditional logic. The result is no item, no gap, and nothing in the plan recording that routing logic existed.

Why this matters here specifically

The project's governing rule is that a failed inference must not read as a confident negative, and collect already closed the analogous hole on the inventory side — referencedBy now scans policy text and expressions, because "a backend id built inside a policy expression was invisible."

The planner has the same hole one level up, and handled is a stronger claim than gap: it asserts that another object carries this.

By contrast, authentication-managed-identity is a sound handled — the provider item genuinely carries it (plan.py:290, 346) and raises the matching RBAC prerequisite (plan.py:1134). The verdict itself isn't the problem; skipping before analysis is.

Suggested fix

For a handled rule, still emit a cross-reference or raise an item when the element carries an expression (expressionIds non-empty) or sits under a conditional path, so the plan says the routing logic existed and what became of it.


Found while documenting the migration flow. Derived from reading the source; not reproduced against a live APIM instance.

Lenguaje dominante
Python
Estrellas
18
Forks
9
Merge medio
1 d 16 h
PR fusionados (30 d)
23

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/aigateway

Todos los issues de Azure/aigateway

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.