Skip to content

Storage: MalformedURLException: no protocol #7004

Closed

Description

@dbarashev

We're using GCS client for Java by constructing it as follows:

  client = StorageOptions.getDefaultInstance().toBuilder().apply {
    this.setRetrySettings(RetrySettings.newBuilder()
        .setInitialRetryDelay(Duration.ofSeconds(1))
        .setMaxRetryDelay(Duration.ofSeconds(1))
        .setRetryDelayMultiplier(1.0)
        .setMaxAttempts(2)
        .setTotalTimeout(Duration.ofSeconds(5))
        .build()
    )
  }.build().service

(this is Kotlin code but it does not matter). When we try to read anything, with the following code:

client.readAllBytes(BlobId.of(gcsBucket, objectId))

we get MalformedURLException:

com.google.cloud.storage.StorageException: java.lang.IllegalArgumentException: java.net.MalformedURLException: no protocol: storage.googleapis.com/download/storage/v1/b/papeeria-eu-dev-download/o/905fd71c1438c46b1295902dcea26061.png?alt=media
	at com.google.cloud.storage.StorageException.translateAndThrow(StorageException.java:74) ~[google-cloud-storage-1.102.0.jar:1.102.0]
	at com.google.cloud.storage.StorageImpl.readAllBytes(StorageImpl.java:596) ~[google-cloud-storage-1.102.0.jar:1.102.0]

It worked fine until recently and it seems that this bug was introduced by this change:
https://github.com/googleapis/google-cloud-java/pull/6579/files

Indeed, if we explicitly set host on builder, it works fine:

  client = StorageOptions.getDefaultInstance().toBuilder().apply {
    this.setRetrySettings(RetrySettings.newBuilder()
        .setInitialRetryDelay(Duration.ofSeconds(1))
        .setMaxRetryDelay(Duration.ofSeconds(1))
        .setRetryDelayMultiplier(1.0)
        .setMaxAttempts(2)
        .setTotalTimeout(Duration.ofSeconds(5))
        .build()
    )
    this.setHost("https://storage.googleapis.com")
  }.build().service

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Dec 10, 2019
  2. JesseLovelace commented on Dec 13, 2019

    @JesseLovelace
    Contributor

    Thank you so much for bringing this to our attention, we'll be fixing this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions