Fix get_caller_pairs: resolve userId across all channels#118
Merged
Conversation
userId was only set from aad_object_id, which is None on non-Teams channels and A2A calls. Add fallback chain: aad_object_id → agentic_user_id → frm.id Port of microsoft/Agent365-dotnet#246 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fpfp100
requested review from
JacksonWeber,
MSNev,
hectorhdzg,
jeremydvoss,
lzchen and
rads-1996
as code owners
May 5, 2026 00:55
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the A365 hosting scope helper so user.id is populated consistently across channels by falling back from aad_object_id to agentic_user_id to the raw from.id, aligning behavior with the referenced .NET change.
Changes:
- Updated
get_caller_pairs()to yielduser.idusing a fallback chain:aad_object_id → agentic_user_id → id. - Added tests covering non-Teams fallback to
from.id, A2A fallback toagentic_user_id, and precedence whenaad_object_idis present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py |
Adjusts caller user.id extraction to include fallback identifiers when aad_object_id is missing. |
tests/a365/hosting/scope_helpers/test_scope_helper_utils.py |
Adds unit tests validating the new fallback and precedence behavior for get_caller_pairs(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rads-1996
approved these changes
May 5, 2026
2 tasks
nikhilNava
pushed a commit
that referenced
this pull request
May 14, 2026
* Revert "Fix get_caller_pairs: resolve userId across all channels (#118)" This reverts commit 97ec7f3. * Fix mypy error caused by requests 2.34.1 HeadersType change requests 2.34.1 changed HeadersType from Mapping to MutableMapping, which is invariant in its value type. Widen headers annotation from dict[str, str] to dict[str, str | bytes] to match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Peng Fan <pefan@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aad_object_id, which isNoneon non-Teams channels and A2A callsaad_object_id → agentic_user_id → frm.idChannel behavior after fix
Test plan
🤖 Generated with Claude Code