Skip to content

refactor(server)!: add build_user function to DefaultContextBuilder to allow A2A user creation customization#925

Merged
guglielmo-san merged 16 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/refactor_server_call_context
Apr 3, 2026
Merged

refactor(server)!: add build_user function to DefaultContextBuilder to allow A2A user creation customization#925
guglielmo-san merged 16 commits intoa2aproject:1.0-devfrom
guglielmo-san:guglielmoc/refactor_server_call_context

Conversation

@guglielmo-san
Copy link
Copy Markdown
Member

@guglielmo-san guglielmo-san commented Apr 2, 2026

Description

  • Add build_user function to the DefaultContextBuilder to allow user customization
  • Renamed CallContextBuilder / DefaultCallContextBuilder -> ServerCallContextBuilder / DefaultServerCallContextBuilder
  • Centralizes HTTP context-building logic into a new a2a.server.routes.common module, eliminating duplication between the JSON-RPC and REST dispatchers.

Fixes #924 🦕

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the context building logic across gRPC, JSON-RPC, and REST adapters by introducing a centralized UserBuilder strategy and a common build_server_call_context function. This replaces the previous class-based CallContextBuilder hierarchy with a more flexible functional approach. I have included a suggestion to improve the robustness of the user_name property in StarletteUser by using getattr with a default value, which aligns with the project's coding conventions.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🧪 Code Coverage (vs 1.0-dev)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/request_handlers/grpc_handler.py 94.61% 94.64% 🟢 +0.03%
src/a2a/server/routes/jsonrpc_dispatcher.py 86.32% 85.23% 🔴 -1.09%
src/a2a/server/routes/common.py (new) 89.66%
Total 91.91% 91.88% 🔴 -0.03%

Generated by coverage-comment.yml

@guglielmo-san guglielmo-san marked this pull request as ready for review April 2, 2026 12:51
@guglielmo-san guglielmo-san requested a review from a team as a code owner April 2, 2026 12:51
@guglielmo-san guglielmo-san requested a review from ishymko April 2, 2026 13:26
@guglielmo-san guglielmo-san changed the title refactor(server)!: replace CallContextBuilder with functional UserBuilder pattern refactor(server)!: add build_user function to DefaultContextBuilder to customize User creation Apr 3, 2026
@guglielmo-san guglielmo-san changed the title refactor(server)!: add build_user function to DefaultContextBuilder to customize User creation refactor(server)!: add build_user function to DefaultContextBuilder to allow A2A user creation customization Apr 3, 2026
@guglielmo-san guglielmo-san enabled auto-merge (squash) April 3, 2026 14:49
@guglielmo-san guglielmo-san merged commit 2648c5e into a2aproject:1.0-dev Apr 3, 2026
15 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/refactor_server_call_context branch April 3, 2026 14:51
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.

2 participants