Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GCS path parsing #181

Merged
merged 1 commit into from Aug 26, 2022
Merged

Fix GCS path parsing #181

merged 1 commit into from Aug 26, 2022

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented Aug 25, 2022

For a path such as gs://delta_sharing_test/foo, getHost will return null and trigger NPE. This PR changes the code to call GCS APIs to parse a path instead to avoid such issue (It calls getAuthority underlying instead).

This is not an issue for S3 or Azure because they do require the bucket name to be a valid host name (cannot contain _).

assert(objectName.nonEmpty, s"cannot get object key from $path")
val blobInfo = BlobInfo.newBuilder(BlobId.of(bucketName, objectName)).build
storage.signUrl(
blobInfo, preSignedUrlTimeoutSeconds, SECONDS, Storage.SignUrlOption.withV4Signature())
.toString
}
}

object GCSFileSigner {
def getBucketAndObjectNames(path: Path): (String, String) = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Create a new method for this so that I can write tests

Copy link
Collaborator

@zhuansunxt zhuansunxt left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@zsxwing zsxwing merged commit 8a2c7c4 into delta-io:main Aug 26, 2022
@zsxwing zsxwing deleted the fix-gcs-path-parsing branch August 26, 2022 02:12
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.

None yet

2 participants