Skip to content

fix(spanner): preserve per-call CallCredentials on DirectPath-to-CloudPath fallback - #15283

Merged
sakthivelmanii merged 1 commit into
mainfrom
fix/spanner-fallback-preserve-call-credentials
Dec 1, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
fix/spanner-fallback-preserve-call-credentials

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem Statement

  • When java-spanner falls back from DirectPath to CloudPath, the CloudPath fallback channel unconditionally overwrites per-call CallCredentials with the client's default credentials.
  • Requests configured with narrower per-call or per-tenant credentials via SpannerOptions.CallCredentialsProvider or CallContextConfigurator silently execute under the broader client default identity after fallback.

Solution

  • Preserve any existing per-call CallCredentials on outgoing CallOptions during DirectPath-to-CloudPath fallback, and attach the client's default credentials only when no call credentials are already present.
  • Construct the default CallCredentials wrapper once during channel setup instead of allocating a new wrapper on every fallback RPC.

…dPath fallback

## Problem Statement
- When `java-spanner` falls back from DirectPath to CloudPath, the CloudPath fallback channel unconditionally overwrites per-call `CallCredentials` with the client's default credentials.
- Requests configured with narrower per-call or per-tenant credentials via `SpannerOptions.CallCredentialsProvider` or `CallContextConfigurator` silently execute under the broader client default identity after fallback.

## Solution
- Preserve any existing per-call `CallCredentials` on outgoing `CallOptions` during DirectPath-to-CloudPath fallback, and attach the client's default credentials only when no call credentials are already present.
- Construct the default `CallCredentials` wrapper once during channel setup instead of allocating a new wrapper on every fallback RPC.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 30, 2026 09:48

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

Copy link
Copy Markdown
Contributor

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 GCP fallback credentials handling in GapicSpannerRpc by introducing a new ClientInterceptor via createFallbackDefaultCredentialsInterceptor. This interceptor ensures that default credentials are only attached to outgoing RPCs on the CloudPath fallback channel when no per-call credentials are already present, thereby preserving custom credentials configured via providers or configurators. Additionally, comprehensive unit tests have been added to GapicSpannerRpcTest to validate this behavior across various fallback scenarios. There are no review comments to address, and the implementation looks solid.

@sakthivelmanii
sakthivelmanii merged commit 67d14cf into main Dec 1, 2026
197 checks passed
@sakthivelmanii
sakthivelmanii deleted the fix/spanner-fallback-preserve-call-credentials branch December 1, 2026 16:50
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