Skip to content

Fix get_caller_pairs: resolve userId across all channels#118

Merged
rads-1996 merged 2 commits into
microsoft:mainfrom
fpfp100:fix/userid-fallback-chain
May 5, 2026
Merged

Fix get_caller_pairs: resolve userId across all channels#118
rads-1996 merged 2 commits into
microsoft:mainfrom
fpfp100:fix/userid-fallback-chain

Conversation

@fpfp100

@fpfp100 fpfp100 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Channel behavior after fix

Field Teams Other channels (aad_object_id None) A2A (user) A2A (agent)
userId aad_object_id frm.id aad_object_id agentic_user_id

Test plan

  • Existing tests pass
  • New test: non-Teams channel — userId falls back to frm.id
  • New test: A2A — userId falls back to agentic_user_id
  • New test: precedence — aad_object_id wins when all set

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 5, 2026 00:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 yield user.id using a fallback chain: aad_object_id → agentic_user_id → id.
  • Added tests covering non-Teams fallback to from.id, A2A fallback to agentic_user_id, and precedence when aad_object_id is 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
rads-1996 merged commit 97ec7f3 into microsoft:main May 5, 2026
8 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants