Skip to content

Expose override_origin on Client.connect() to set gRPC :authority header#3

Merged
serge-wq merged 1 commit intolyft-stable-1.26.0from
sergiof/override-origin-stable
Apr 29, 2026
Merged

Expose override_origin on Client.connect() to set gRPC :authority header#3
serge-wq merged 1 commit intolyft-stable-1.26.0from
sergiof/override-origin-stable

Conversation

@serge-wq
Copy link
Copy Markdown

@serge-wq serge-wq commented Apr 29, 2026

Summary

  • Adds override_origin: str | None = None to Client.connect() (and CloudOperationsClient.connect()), wired through ConnectConfig → Python bridge → Rust Core ConnectionOptions::override_origin
  • Sets the HTTP/2 :authority pseudo-header on every gRPC call, enabling Python workers to connect through an Envoy sidecar that routes by :authority
  • Achieves feature parity with the Go SDK (client.Options.HostPort) and Rust Core (ConnectionOptions::override_origin)

This is a cherry-pick of the same change from sergiof/override-origin (targeting upstream temporalio/sdk-python:main). After internal validation here, we will open the upstream PR.

Test plan

  • Unit tests: test_connect_config_override_origin_forwarded_to_bridge, test_connect_config_override_origin_defaults_to_none
  • Integration test: test_override_origin_end_to_end — spins up a grpc.aio fake WorkflowService, connects with override_origin set, confirms GetSystemInfo is called and standard gRPC metadata is intact
  • Error test: test_override_origin_invalid_uri_raises — confirms a bad URI string raises ValueError before any network call
  • test_client_connect_config_matches_connect_params guard passes (TypedDict in sync)
  • Manual validation: deploy a Python worker with override_origin="http://temporal-frontend" and confirm it connects through Envoy to the CloudSec Temporal instance

🤖 Generated with Claude Code

Thread a new `override_origin` string parameter from the public Python API
(`Client.connect()`) through the Python/Rust bridge down to the Rust Core
`ConnectionOptions::override_origin` field, which sets the HTTP/2 `:authority`
pseudo-header on every gRPC call.

This achieves feature parity with the Go SDK (`client.Options.HostPort`) and
unblocks Python workers that connect to a Temporal cluster through an Envoy
sidecar: Envoy routes by `:authority`, but without this option the Python SDK
always sends `localhost:<port>` as the authority, which Envoy does not recognise
as a valid upstream cluster.

Changes:
- temporalio/bridge/Cargo.toml: add `http = "1"` dep for Uri parsing
- temporalio/bridge/src/client.rs: add override_origin field; call
  .maybe_override_origin() on the ConnectionOptions builder
- temporalio/bridge/client.py: add override_origin field to ClientConfig
- temporalio/service.py: add override_origin field to ConnectConfig; thread
  through _to_bridge_config()
- temporalio/client.py: add override_origin kwarg to Client.connect() and
  CloudOperationsClient.connect(); add to ClientConnectConfig TypedDict
- tests/test_service.py: unit tests for bridge wiring + integration test
  using a grpc.aio fake server + error test for invalid URI

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@serge-wq serge-wq merged commit 57dd970 into lyft-stable-1.26.0 Apr 29, 2026
2 checks passed
@serge-wq serge-wq deleted the sergiof/override-origin-stable branch April 29, 2026 19:31
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