HTTPError.contentType - HTTP message did not have JSON-compatible content-type when unwrapping Future<Object> with flatMap

I am using this Vapor Google Cloud Storage library in order to get objects from my GCP buckets and display those objects to a specific endpoint in my Leaf website.

After calling the get object function provided by the library, I am returned an EventLoopFuture<GoogleStorageObject> - I call flatMap(to:) on the EventLoopFuture<GoogleStorageObject> in order to grab the actual GoogleStorageObject and use the properties I need however I get this error inside the flatMap: HTTPError.contentType - HTTP message did not have JSON-compatible content-type.

I don’t understand why it is giving me this error inside the flatMap since the type of data returned defaults to json, also when I get the list of buckets and am returned EventLoopFuture<GoogleStorageBucketList> and I call flatMap(to:) on that object, it unwraps the future into GoogleStorageBucketList object with no issues which leads me to believe I am calling flatMap(to:) appropriately so I would appreciate some help if anyone has used the same library or encountered the similar error. Thanks in advance!

Below is a screenshot of my code and the error message along with comments that break down what I mentioned I did above.


It looks like the get(bucket:objectName:) call is failing. Add a catchMap or similar to the flatMap call to inspect the error it returns or breakpoint and jump inside

When I add catchMap to the flatMap and print the error, It just gives me the same error [HTTPError.contentType: HTTP message did not have JSON-compatible content-type.] and when I breakpoint on line 99 where the flatMap is called and jump inside, the code breaks with the same error inside some random code which I think is located in EventLoopFuture.swift and the value is never reached.

I know i’m not naming the name of my bucket or object wrong because I copied/pasted the string and my permissions are correct considering Im not getting a 403 Forbidden error, there does not seem to be a reasonable explanation for why the call fails

The images in this comment depict how my files are organized in my GCP Storage Bucket in order to help illustrate the points I am about to make.

Few things to point out:

  1. When I try to pull the object and it is placed inside a folder within my bucket, ex)
  • Buckets / :bucket_name / images / icon.png
    Images related to this example, notice I am inside images/ 34%20AM 52%20AM

  • I receive the HTTPError.contentType: HTTP message did not have JSON-compatible content-type.
  1. When I place the file directly under the bucket with no folder, ex)
  • Buckets / :bucket_name / icon.png

  • I do not receive any error and am able to pull the object with no problems

It’s become obvious that this content-type error is showing up because of the folders, however I need to keep my files organized within folders in my bucket. Im wondering if this is a minor bug with the Vapor GCP Storage library or if it’s a GCP issue since the their “Folder” objects can’t be appropriately parsed into JSON, or if this is just a Vapor bug???

It’s sounds like a bug in the GCP library written for Vapor - I’d report an issue there on their GH