Skip to content

fix(storage): send signed URL upload requests without client-level headers - #15132

Draft
Dhriti07 wants to merge 1 commit into
mainfrom
storage-signed-url-upload
Draft

Dhriti07 wants to merge 1 commit into
mainfrom
storage-signed-url-upload

Conversation

@Dhriti07

Copy link
Copy Markdown
Contributor

Send signed URL upload requests without client-level headers.

…aders

Send signed URL upload requests without client-level headers.

@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 adds support for signed URLs in resumable uploads, ensuring that client headers (such as authorization and custom headers) are excluded when writing to a signed URL. To support this, a new forSignedUrl factory method is added to HttpClientContext, and HttpStorageRpc is updated to manage a dedicated signedUrlRequestFactory. However, a critical issue was identified in HttpClientContext.forSignedUrl: the method accepts a StorageRpc parameter but attempts to call getStorage(), which is not defined on the StorageRpc interface. It is recommended to change the parameter type to HttpStorageRpc directly to ensure compile-time safety.

Comment on lines +82 to +89
static HttpClientContext forSignedUrl(StorageRpc storageRpc) {
HttpRequestFactory requestFactory =
storageRpc instanceof HttpStorageRpc
? ((HttpStorageRpc) storageRpc).getSignedUrlRequestFactory()
: storageRpc.getStorage().getRequestFactory().getTransport().createRequestFactory();
return new HttpClientContext(
requestFactory, storageRpc.getStorage().getObjectParser(), Tracing.getTracer());
}

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.

critical

The current implementation of forSignedUrl will fail to compile because storageRpc is declared as StorageRpc, which does not define the getStorage() method. Since HttpClientContext is specific to HTTP transport, we should use HttpStorageRpc as the parameter type directly to ensure compile-time safety, rather than generalizing to StorageRpc and casting.

  static HttpClientContext forSignedUrl(HttpStorageRpc storageRpc) {
    return new HttpClientContext(
        storageRpc.getSignedUrlRequestFactory(),
        storageRpc.getStorage().getObjectParser(),
        Tracing.getTracer());
  }
References
  1. Use specific transport classes as parameter types for helper methods designed to run on top of that specific transport to ensure compile-time safety, rather than generalizing to a generic class.

This branch has not been deployed

No deployments
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.

1 participant