Merge User-Agent headers when cloning HTTP client#383
Merged
heyitsaamir merged 3 commits intomainfrom Apr 13, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/microsoft/teams.py/sessions/ddf00433-ed81-4239-997d-652fbfc4ec72 Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update HTTP client to merge User-Agent headers on clone
Merge User-Agent headers when cloning HTTP client
Apr 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the common HTTP Client.clone() behavior so User-Agent headers are merged (instead of overwritten) when callers supply additional headers during cloning, preserving the SDK’s default UA token.
Changes:
- Added
_merge_headers(base, overrides)to merge headers with special-caseUser-Agentconcatenation. - Updated
Client.clone()to use_merge_headers()for header merging. - Added unit tests covering
User-Agentmerge behavior and edge cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/common/src/microsoft_teams/common/http/client.py | Adds header merge helper and switches clone() to UA-aware merging. |
| packages/common/tests/test_client.py | Adds clone-related tests validating UA preservation/merging and dedup behavior. |
heyitsaamir
approved these changes
Apr 12, 2026
- Store User-Agent under canonical key when base headers have none - Add test for key normalization when override uses lowercase - Add test for multi-token User-Agent override Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lilyydu
approved these changes
Apr 13, 2026
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.
When
Client.clone()was called with headers containing aUser-Agent, it would overwrite the base client'sUser-Agentrather than merging. This loses the SDK's default UA token when callers supply their own.Changes
packages/common/src/microsoft_teams/common/http/client.py_merge_headers(base, overrides)helper: performs a case-insensitiveUser-Agentmerge (space-concatenated, token-based dedup to avoid substring false positives); all other headers follow standard last-write-wins semanticsClient.clone()now calls_merge_headers()instead of a plain dict unpackpackages/common/tests/test_client.pyExample
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
releases.astral.sh/home/REDACTED/.local/bin/uv uv sync --all-packages --group dev(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created from Copilot chat.