Exception thrown during upload.
ClaireNeveu opened this issue · 4 comments
We were attempting to upgrade our version of the library to the latest and we began encountering this error during image upload
org.json4s.package$MappingException: unknown error
In:
JObject(List((public_id,JString(ise26l8mxqm5adgerxpf)), (version,JInt(1432652459)), (signature,JString(b84a3167bb4032068f4677b8f862898c79831f20)), (width,JInt(636)), (height,JInt(457)), (format,JString(jpg)), (resource_type,JString(image)), (created_at,JString(2015-05-26T15:00:59Z)), (tags,JArray(List())), (bytes,JInt(201588)), (type,JString(upload)), (etag,JString(88aa9ceb7337c44a52a70419779d8dde)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (eager,JArray(List(JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_358,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_358,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_358,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_358,q_80,w_636/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_470/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_470/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_264,q_80,w_470/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_264,q_80,w_470/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fit,fl_progressive,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_180,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_180,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_180,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_180,q_80,w_320/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_77,q_80,w_137/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_north,h_77,q_80,w_137/v1432652459/ise26l8mxqm5adgerxpf.jpg)))), JObject(List((status,JString(processing)), (batch_id,JString(4f1d457168618571ec18124e2bb1669cba4fed0ffa538d62bd8bdcf7c9e2f1315b62b16020207338b0445882f5c7743a)), (url,JString(http://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_77,q_80,w_137/v1432652459/ise26l8mxqm5adgerxpf.jpg)), (secure_url,JString(https://res.cloudinary.com/gawker-media/image/upload/c_fill,fl_progressive,g_center,h_77,q_80,w_137/v1432652459/ise26l8mxqm5adgerxpf.jpg)))))))))
at com.cloudinary.HttpClient$$anonfun$executeAndExtractResponse$1.apply(HttpClient.scala:61) ~[cloudinary-core-scala_2.10-0.9.7.1.jar:0.9.7.1]
at com.cloudinary.HttpClient$$anonfun$executeAndExtractResponse$1.apply(HttpClient.scala:54) ~[cloudinary-core-scala_2.10-0.9.7.1.jar:0.9.7.1]
at scala.util.Success$$anonfun$map$1.apply(Try.scala:206) ~[scala-library.jar:na]
at scala.util.Try$.apply(Try.scala:161) ~[scala-library.jar:na]
at scala.util.Success.map(Try.scala:206) ~[scala-library.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) ~[scala-library.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235) ~[scala-library.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) ~[scala-library.jar:na]
at scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) ~[scala-library.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) ~[scala-library.jar:na]This is how we use the library:
// url : String, eager : List[Size], pId : Option[String], async : Boolean, moderated : Boolean
try {
val eagerTransforms = eager.map(sizeToTransformation)
val up = pId.map(UploadParameters()
.publicId(_)).getOrElse(UploadParameters())
.eager(eagerTransforms)
.eagerAsync(async)
.tags(if (url.takeWhile(_ != '?').endsWith(".gif")) Set("gif") else Set())
val params =
if (moderated)
up.moderation("webpurify")
else
up
cloud.uploader().upload(url, params).map {
response => ImageResponse(response.raw)
} recoverWith (handleUploadErrors andThen Future.failed)
} catch (handleUploadErrors andThen Future.failed))Hi @ChrisNeveu
I can't seem to be able to reproduce the issue.
this is the spec I'm running:
it should "support uploading with eager async transformations" taggedAs(EagerTest) in {
val eagerTransforms = List(Transformation().c_("scale").w_(0.5), Transformation().c_("scale").w_(0.4))
val uploadParams = UploadParameters().eager(eagerTransforms).eagerAsync(true)
Await.result(for {
response <- cloudinary.uploader().upload("http://cloudinary.com/images/logo.png", uploadParams)
} yield {
response.eager.length should equal(2)
}, 10.seconds)
}Can you please try to run it in your environment?
Are you using a different json4s version from 3.2.10? Do you perhaps have dependency on more than one version?
We only depend on json4s through Cloudinary.
The following example throws an exception in our code:
val eagerTransforms = List(Transformation())
val uploadParams = UploadParameters().eager(eagerTransforms).eagerAsync(true).tags(Set())
Await.result(for {
response <- cloudinary.uploader().upload("http://i.kinja-img.com/gawker-media/image/upload/tragfjufpswym5ilco8e.jpg", uploadParams)
} yield {
response.raw
}, 10.seconds)I tried to write a test to confirm but your test suite does not work for me. Every test throws a NullPointerException
[info] An Uploader
[info] - should upload a file and get sizes, colors, predominant, public_id, version and signature back *** FAILED ***
[info] java.lang.NullPointerException:
[info] at java.net.URI$Parser.parse(URI.java:3023)
[info] at java.net.URI.<init>(URI.java:595)
[info] at com.cloudinary.Cloudinary$.configFromUrl(Cloudinary.scala:20)
[info] at com.cloudinary.Cloudinary.<init>(Cloudinary.scala:129)
[info] at com.cloudinary.UploaderSpec.cloudinary$lzycompute(UploaderSpec.scala:19)
[info] at com.cloudinary.UploaderSpec.cloudinary(UploaderSpec.scala:18)
[info] at com.cloudinary.UploaderSpec$$anonfun$1.apply$mcV$sp(UploaderSpec.scala:30)
[info] at com.cloudinary.UploaderSpec$$anonfun$1.apply(UploaderSpec.scala:28)
[info] at com.cloudinary.UploaderSpec$$anonfun$1.apply(UploaderSpec.scala:28)
[info] at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)It might also be worth mentioning that we are constructing our Cloudinary instance with a cname:
private lazy val cloud = new Cloudinary(Map(
"cloud_name" -> apiName,
"api_key" -> apiKey,
"api_secret" -> apiSec,
"cname" -> "i.kinja-img.com"))After a lot more testing, we've discovered the cause of the issue. While we weren't depending on a different version of json4s, we were depending on the same version down the line. Something with how this all got packaged up was messing with json4s' reflection and causing the exception. We've removed our dependency, instead relying on the implicit dependency from the cloudinary_scala library and everything works now.