Skip to content

feat(generator): wire transport stub delegation to resumable upload stubs - #14322

Open
whowes wants to merge 1 commit into
mainfrom
whowes/generator-transport-stub-delegation
Open

whowes wants to merge 1 commit into
mainfrom
whowes/generator-transport-stub-delegation

Conversation

@whowes

@whowes whowes commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Wires generated transport stubs (GrpcServiceStub, HttpJsonServiceStub) to delegate resumable upload methods to the internal HTTP upload stub, and excludes upload RPCs from the main stubs' method descriptors and callables.

@whowes
whowes added this pull request to stack #14327 September 9, 2026 06:35
gemini-code-assist[bot]

This comment was marked as outdated.

@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch 2 times, most recently from e42be42 to 30a1067 Compare September 9, 2026 19:35
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 30a1067 to e1bb5fb Compare September 9, 2026 20:17
@whowes
whowes removed this pull request from stack #14327 September 9, 2026 23:45
@whowes
whowes added this pull request to stack #14343 September 9, 2026 23:47
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch 2 times, most recently from c910ed3 to 3fb2567 Compare September 10, 2026 00:19
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 3fb2567 to daaf68a Compare September 10, 2026 01:15
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from daaf68a to 7ca783c Compare September 10, 2026 06:05
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 7ca783c to 9905b6e Compare September 11, 2026 17:24
@whowes
whowes removed this pull request from stack #14343 September 11, 2026 17:25
@whowes
whowes added this pull request to stack #14363 September 11, 2026 17:25
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 9905b6e to 66afa95 Compare September 11, 2026 18:30
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 66afa95 to 26d0fde Compare September 11, 2026 20:00
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 26d0fde to 136e9ce Compare September 11, 2026 21:14
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 136e9ce to 1ddd21b Compare September 11, 2026 21:39
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 1ddd21b to 08ecb13 Compare September 11, 2026 22:15
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 4d9fb44 to c77488e Compare September 15, 2026 23:14
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from c77488e to b768584 Compare September 15, 2026 23:43
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from b768584 to db79f9b Compare September 16, 2026 00:46
this.resumableUploadStub = null;
}

if (resumableUploadStub != null) {

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.

resumableUploadStub is only generated if resumable upload methods exist, so I don't think we need this null check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reworked this to look a bit less awkward - but the stub can also be null if the user initialized the client with a gRPC channel and credentials can't be extracted (so that init succeeds but calls to the resumable upload stub fail fast).

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.

It is a possible scenario but I'm not sure how we can detect that actually. Customers can pass a FixedChannelProvider with their custom gRPC channel and credentials. In this case, we would still create a resumable upload stub with a default credential provider, but it would not work. I think we may have to let it fail during runtime.

@whowes whowes Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, yeah I see that the current check is insufficient. I don't think we can just let calls fail at runtime though; we have a requirement that "when a gRPC client surface for a resumable upload API is initialized with a pre-constructed gRPC Channel, the Client Libraries must raise a detailed (actionable) error if a resumable method is called". So we need to be able to distinguish between this case and other failures.

WDYT about switching the check to be if (settings.getTransportChannelProvider() instanceof InstantiatingGrpcChannelProvider), is that sufficient to detect the custom channel or are there gotchas about that way too?

It also wouldn't necessarily have to be here at the top level; it could get pushed into HttpJson<Service>ResumableUploadStub.create(...) and set the callable there to throw with the actionable error. Then the specialized stub could be always non-null for services that need resumable uploads.

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.

WDYT about switching the check to be if (settings.getTransportChannelProvider() instanceof InstantiatingGrpcChannelProvider), is that sufficient to detect the custom channel or are there gotchas about that way too?

The default grpc channel is also InstantiatingGrpcChannelProvider.

we have a requirement that "when a gRPC client surface for a resumable upload API is initialized with a pre-constructed gRPC Channel, the Client Libraries must raise a detailed (actionable) error if a resumable method is called"

The way I interpreted it is that we should be good as long as we surface the runtime error (likely an auth error) to the customer. It does not have to be an error before making the call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DIscussed offline - we will pause on detecting the custom gRPC channel and unconditionally create the specialized stub (so now it's always non-null). This PR is now in that state.

We clarified that it is still a requirement to provide a more actionable error than bubbling up whatever may happen to fail when a resumable upload method is called if the client library was initialized with a gRPC channel, but we will defer adding that functionality for now.


if (clientContext.getCredentials() != null) {
this.resumableUploadStub =
HttpJsonResumableUploadServiceResumableUploadStub.create(clientContext, settings);

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.

As I mentioned in another comment, we might be able to just pass the settings to HttpJsonResumableUploadServiceResumableUploadStub.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Responded in more detail on that thread - I'm not sure what the best tradeoff there is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is now using the settings directly

@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from db79f9b to 627610b Compare September 16, 2026 05:47
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 627610b to 6341e4e Compare September 17, 2026 18:11
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch 2 times, most recently from 378b601 to 0416f83 Compare September 18, 2026 04:30
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 0416f83 to 1b3fd06 Compare September 18, 2026 15:03
@whowes
whowes marked this pull request as ready for review September 18, 2026 15:10
@whowes
whowes requested review from a team as code owners September 18, 2026 15:10
@whowes
whowes requested a review from blakeli0 September 18, 2026 15:10
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 1b3fd06 to ba9463b Compare September 18, 2026 18:17
Base automatically changed from whowes/generator-resumable-upload-stub-composer to main September 18, 2026 22:20
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch 2 times, most recently from 443d75f to 2ffa0af Compare September 18, 2026 23:08
@whowes
whowes removed this pull request from stack #14390 September 18, 2026 23:50
…tubs

Wires the generated transport stubs (GrpcServiceStub and HttpJsonServiceStub) to delegate resumable upload methods to the internal HTTP upload stub. In GrpcServiceStub, credentials, headers, and clocks are forwarded to the underlying HTTP client context. Clients initialize successfully without credentials; an exception results only if use of the HTTP upload stub is attempted.

Also declares the stub-side contract that the transports implement:

- In AbstractServiceStubClassComposer: emit public
  ResumableUploadCallable<RequestT, ResponseT> [method]Callable() throwing
  UnsupportedOperationException.
@whowes
whowes force-pushed the whowes/generator-transport-stub-delegation branch from 2ffa0af to c08a674 Compare September 19, 2026 00:07
@whowes
whowes added this pull request to stack #14442 September 19, 2026 00:11
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

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