[WIP] http (feature): Support adding attachment to the request#3952
Closed
[WIP] http (feature): Support adding attachment to the request#3952
Conversation
Copilot stopped work on behalf of
xerial due to an error
June 2, 2025 21:13
xerial
added a commit
that referenced
this pull request
Jul 19, 2025
Adds a mutable attachment field to HttpMessage.Request to allow attaching context information (RPC context, logging context, authorized user info) that travels with the request. This replaces unreliable thread-local storage approaches. Key changes: - Add ConcurrentHashMap-based attachment storage to Request - Provide type-safe getter/setter methods for attachments - Ensure attachments are preserved when copying requests - Comprehensive test coverage for all attachment operations The case class parameters remain immutable; only the attachment map is mutable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
xerial
added a commit
that referenced
this pull request
Jul 19, 2025
## Summary - Adds a mutable attachment field to `HttpMessage.Request` to allow attaching context information (RPC context, logging context, authorized user info) that travels with the request - Replaces unreliable thread-local storage approaches with request-scoped attachments - Implements issue #3952 ## Key changes - Add `ConcurrentHashMap`-based attachment storage to Request class - Provide type-safe getter/setter methods for managing attachments - Ensure attachments are preserved when copying requests (using Scala's `++=` operator) - Add comprehensive test coverage for all attachment operations ## Implementation details - The case class parameters remain immutable; only the attachment map is mutable - Uses `ConcurrentHashMap` for thread-safe concurrent access - Attachments are automatically copied when creating modified requests via `withX` methods ## Test plan ✅ Unit tests added for: - Basic get/set/remove operations - Attachment preservation during request copying - Concurrent access safety - Complex attachment types support All tests pass successfully. 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <[email protected]>
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.
The goal is to support adding context parameters (RPC context, logging context) to HTTP requests using a mutable attachment system while maintaining immutability for other request parameters.
Fixes #3880.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.