[v3 wrappers] Make session request-adapter caching Graph-profile-aware
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp, powershell
Línea de trabajo
Start with SessionAdapterCache.cs and GraphClientCmdlet.cs to trace how the session HttpClient selects and reuses adapters, then inspect CmdletEmitter.cs for the profile passed by generated wrappers. Review SessionAdapterCacheTests.cs and add stub-transport URI regressions for both profile invocation orders, including reuse and client replacement; done means requests retain the intended profile without stale session transport.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Track the shared runtime/generator routing problem discussed in #3839 for a separate follow-up PR, rather than extending the Bookings retirement change.
When wrapper cmdlets use the active Connect-MgGraph session without -AccessToken, GraphClientCmdlet.GetRequestAdapter() returns an adapter from SessionAdapterCache. The cache is keyed only by reference identity of the session HttpClient, so v1.0 and beta wrappers share one adapter. Generated Kiota clients set RequestAdapter.BaseUrl to their profile URL only when it is empty, then capture that value in their path parameters.
Consequently, the first profile used in a session wins: running a v1.0 wrapper first can make subsequent beta Bookings cmdlets call /v1.0/...; running beta first can make subsequent v1.0 wrappers call /beta/.... The correct /solutions/bookingBusinesses path does not prevent this API-version misrouting.
Expected behavior
Each wrapper uses its intended Graph profile regardless of invocation order or concurrent activity. Adapters may be reused for the same session transport and profile, but must not share mutable profile-specific BaseUrl state across v1.0 and beta.
Retain the existing session transport and lifecycle behavior: reconnecting, changing request context, or disconnecting must not leave requests bound to a stale session HttpClient.
How to reproduce
Code-derived reproduction scenario from review; no live Graph request reproduction was performed while filing this issue:
- Establish a
Connect-MgGraphsession and use wrapper cmdlets without-AccessToken. - Invoke a v1.0 wrapper command, for example from Calendar, so its client initializes the cached adapter's base URL to
https://graph.microsoft.com/v1.0. - Invoke a beta Bookings wrapper command in the same session. Its generated client sees a nonempty adapter base URL and retains
/v1.0instead of selecting/beta. - Repeat with beta first, then v1.0, to observe the reverse routing risk.
Add deterministic tests that capture outgoing request URIs with a stub transport, without depending on live Graph data.
SDK Version
Unreleased powershell-v3 wrapper implementation, observed during #3839 at commit 037ab5db249e97a44338a0b08a2ecb0dc67e0e23. No claim is made about released v2 service modules.
Latest version known to work for scenario above?
Unknown.
Known Workarounds
Supplying -AccessToken currently creates a separate request adapter per invocation and bypasses this session adapter cache. This is a different authentication path, not a fix for session-based usage.
Do not fix this by unconditionally overwriting the shared adapter's BaseUrl: that still mutates shared state and can misroute concurrent or subsequent requests. Removing caching outright also loses its session-lifecycle purpose.
Debug output
N/A. Report based on the referenced review discussion and current runtime/generator source inspection; no live request logs were collected.
Configuration
Applies to v1.0 and beta wrapper modules sharing the same session HttpClient. No OS-specific dependency identified; runtime reproduction across PowerShell editions has not been performed.
Other information
Relevant sources:
src/GraphWrapperRuntime/Runtime/SessionAdapterCache.cs: single cached adapter keyed only by session client identity.src/GraphWrapperRuntime/Runtime/GraphClientCmdlet.cs: adapter acquisition does not receive a Graph profile.tools/WrapperGenerator/CmdletEmitter.cs: emits parameterlessGetRequestAdapter()calls.src/Bookings/wrapper/beta/Client/ApiClient.cs: profile base URL is assigned only when the adapter base URL is empty.src/GraphWrapperRuntime/Runtime.Tests/SessionAdapterCacheTests.cs: existing session-client reuse/replacement coverage.
Suggested follow-up scope and acceptance criteria:
- Make adapter acquisition and cache identity profile-aware, for example
(session HttpClient reference, Graph profile), while preserving the authenticated session transport. - Update the generator to supply the intended profile and regenerate affected wrapper sources through the established workflow; avoid hand-editing generated clients.
- Add same-session v1.0 → beta → v1.0 and beta → v1.0 → beta request-URI regressions.
- Cover same-profile reuse, distinct adapters for different profiles, client replacement/context changes, and interleaved or concurrent requests without cross-profile mutation.
- Keep
-AccessTokenbehavior and the supported Bookings/solutions/...cmdlet surface unchanged.
Original finding: https://github.com/microsoftgraph/msgraph-sdk-powershell/pull/3839#discussion_r4405262434
Follow-up explanation requested for tracking: https://github.com/microsoftgraph/msgraph-sdk-powershell/pull/3839#discussion_r4405694648
- Lenguaje dominante
- C#
- Estrellas
- 904
- Forks
- 235
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 18
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoftgraph/msgraph-sdk-powershell
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microsoftgraph/msgraph-sdk-powershell#3752 ·
Los mantenedores suelen responder en 1 día
-
Tracking for V3 UpgradePosiblemente ocupada @ramsessanchez la tomó hace 1 día. Abiertotype:epic
microsoftgraph/msgraph-sdk-powershell#3874 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
microsoftgraph/msgraph-sdk-powershell#3872 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
microsoftgraph/msgraph-sdk-powershell#3831 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
microsoftgraph/msgraph-sdk-powershell#3827 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoftgraph/msgraph-sdk-powershell
Issues similares
-
area: core priority: low type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
RicoSuter/Namotion.Interceptor#863 ·
Los mantenedores suelen responder en 1 día
-
area-cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
0.3.0
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 2 días
-
[Bug] Decompression leaves metadata that makes recompression throw and corrupt the content typeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BrighterCommand/Brighter#4683 ·
Los mantenedores suelen responder en 1 día