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

Bug: ObjectStoreRegistry get_by_uri does not return correct path when "scheme" is provided #2525

Closed
timvw opened this issue May 13, 2022 · 0 comments · Fixed by #2526
Closed
Labels
bug Something isn't working

Comments

@timvw
Copy link
Contributor

timvw commented May 13, 2022

Describe the bug
object_store_registry.get_by_uri does not work as expected.

To Reproduce && Expected behavior

    #[test]
    fn test_get_by_uri_s3() {
        let sut = ObjectStoreRegistry::default();
        sut.register_store("s3".to_string(), Arc::new(LocalFileSystem {}));
        let uri = "s3://bucket/key";
        let (_, path) = sut.get_by_uri(uri).unwrap();
        assert_eq!(path, "bucket/key");
    }

    #[test]
    fn test_get_by_uri_file() {
        let sut = ObjectStoreRegistry::default();
        let uri = "file:///bucket/key";
        let (_, path) = sut.get_by_uri(uri).unwrap();
        assert_eq!(path, "/bucket/key");
    }

    #[test]
    fn test_get_by_uri_local() {
        let sut = ObjectStoreRegistry::default();
        let uri = "/bucket/key";
        let (_, path) = sut.get_by_uri(uri).unwrap();
        assert_eq!(path, "/bucket/key");
    }

Additional context
This issue is not uncovered with local files, because LocalFileSystem does some additional "magic" to workaround the issue:

impl ObjectStore for LocalFileSystem {
    async fn list_file(&self, prefix: &str) -> Result<FileMetaStream> {
        let prefix = if let Some((_scheme, path)) = prefix.split_once("://") {
            path
        } else {
            prefix
        };
        list_all(prefix.to_owned()).await
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant