Skip to content

Commit 6743864

Browse files
committed
Fix memory corruption: dont pass API key to Rust when using grpc override
1 parent 8f07325 commit 6743864

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Sources/Temporal/Bridge/BridgeClient.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,26 @@ package struct BridgeClient: ~Copyable, Sendable {
265265
// has to be a valid URL, otherwise input validation fails
266266
try "https://dummy.temporal.com".withByteArrayRef { dummy_target_url in
267267
try "".withByteArrayRef { empty_string in
268-
// Pass API key to Rust core if provided
269-
try (configuration.apiKey ?? "").withByteArrayRef { api_key_bytes in
270-
let options = TemporalCoreClientOptions(
271-
target_url: dummy_target_url, // Dummy URL as gRPC connection is handled by Swift
272-
client_name: client_name,
273-
client_version: client_version,
274-
metadata: empty_string,
275-
api_key: api_key_bytes, // Now passes the actual API key to Rust core
276-
identity: identityBytes,
277-
tls_options: nil, // Empty TLS config as auth is handled by Swift
278-
retry_options: nil, // Default is picked when passing `nil`
279-
keep_alive_options: nil, // Default is picked when passing `nil`, HTTP2 gRPC keep alive enabled.
280-
http_connect_proxy_options: nil,
281-
grpc_override_callback: grpcCallback,
282-
grpc_override_callback_user_data: grpcCallbackUserDataPointer
283-
)
268+
// NOTE: API key is NOT passed to Rust core because we use grpc_override_callback.
269+
// When using grpc_override_callback, Swift handles ALL gRPC communication including auth.
270+
// The authorization header is set in TemporalClient.swift instead.
271+
let options = TemporalCoreClientOptions(
272+
target_url: dummy_target_url, // Dummy URL as gRPC connection is handled by Swift
273+
client_name: client_name,
274+
client_version: client_version,
275+
metadata: empty_string,
276+
api_key: empty_string, // Empty - auth is handled by Swift via grpc_override_callback
277+
identity: identityBytes,
278+
tls_options: nil, // Empty TLS config as auth is handled by Swift
279+
retry_options: nil, // Default is picked when passing `nil`
280+
keep_alive_options: nil, // Default is picked when passing `nil`, HTTP2 gRPC keep alive enabled.
281+
http_connect_proxy_options: nil,
282+
grpc_override_callback: grpcCallback,
283+
grpc_override_callback_user_data: grpcCallbackUserDataPointer
284+
)
284285

285-
return try withUnsafePointer(to: options) { unsafe_options in
286-
try body(unsafe_options)
287-
}
286+
return try withUnsafePointer(to: options) { unsafe_options in
287+
try body(unsafe_options)
288288
}
289289
}
290290
}

0 commit comments

Comments
 (0)