-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Crash when field data
is missing in formdata #90
Description
Hi, when constructing a formData object that I pass in intro rnfb.fetch('POST'...
, and having the data
attribute missing, the library crashes:
com.facebook.react.bridge.NoSuchKeyException: couldn't find key data in dynamic object
at com.facebook.react.bridge.ReadableNativeMap.getString(Native Method)
at com.RNFetchBlob.RNFetchBlobBody.countFormDataLength(RNFetchBlobBody.java:242)
at com.RNFetchBlob.RNFetchBlobBody.writeFormData(RNFetchBlobBody.java:84)
at com.RNFetchBlob.RNFetchBlobBody.writeTo(RNFetchBlobBody.java:70)
at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:704)
at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
at okhttp3.RealCall.getResponse(RealCall.java:241)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
at com.RNFetchBlob.RNFetchBlobReq$1.intercept(RNFetchBlobReq.java:276)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
I know that is not the newest version of rnfb, but it still should happen in the newest as that code didn't change in the writeTo
method of the RNFetchBlobBody
.
So a simple check field.hasKey("data")
and rejecting the promise when not would be enough, but where would you put that logic? You know better then me.
Another point, the source of my problem was, that rnfb.wrap(uri)
didn't work properly, probably returned undefined
, as I'm using it to get a file.
I don't know the specific uri yet that the user took, but the user used Android 6.0 and definitely could access the file via cameraroll.
I try to construct an uri that can reproduce the bug, but wanted you to know this bug already.
Thanks!