SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Restheart 3.0.0 throws BsonInvalidOperationException #202

Closed grossmueller-espirit closed 7 years ago

grossmueller-espirit commented 7 years ago

Hi there, when accessing files, for example using"http://localhost:8080/testProject/assets.files/file1/binary", we get the following response:

{  
   "http status code":500,
   "http status description":"Internal Server Error",
   "message":"Error handling the request, see log for more information",
   "_embedded":{  
      "rh:exception":[  
         {  
            "exception":"org.bson.BsonInvalidOperationException",
            "exception message":"Value expected to be of type OBJECT_ID is of unexpected type STRING"
         }
      ]
   },
   "_links":{  
      "self":{  
         "href":"/testProject/assets.files/file1/binary"
      }
   }
}

This is the corresponding exception in the log:

13:59:01.686 [XNIO-1 task-7] ERROR org.restheart.handlers.ErrorHandler - Error handling the request
org.bson.BsonInvalidOperationException: Value expected to be of type OBJECT_ID is of unexpected type STRING
    at org.bson.BsonValue.throwIfInvalidType(BsonValue.java:419)
    at org.bson.BsonValue.asObjectId(BsonValue.java:150)
    at org.restheart.handlers.files.GetFileBinaryHandler.sendBinaryContent(GetFileBinaryHandler.java:184)
    at org.restheart.handlers.files.GetFileBinaryHandler.handleRequest(GetFileBinaryHandler.java:95)
    at org.restheart.handlers.RequestDispacherHandler.handleRequest(RequestDispacherHandler.java:457)
    at org.restheart.handlers.injectors.CollectionPropsInjectorHandler.handleRequest(CollectionPropsInjectorHandler.java:99)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.handlers.injectors.DbPropsInjectorHandler.handleRequest(DbPropsInjectorHandler.java:92)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.handlers.injectors.AccountInjectorHandler.handleRequest(AccountInjectorHandler.java:56)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.AccessManagerHandler.handleRequest(AccessManagerHandler.java:55)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.AuthTokenInjecterHandler.handleRequest(AuthTokenInjecterHandler.java:70)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:54)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:55)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:61)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:85)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.SecurityHandler.handleRequest(SecurityHandler.java:50)
    at org.restheart.security.handlers.SecurityHandlerDispacher.handleRequest(SecurityHandlerDispacher.java:60)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.handlers.injectors.BodyInjectorHandler.handleRequest(BodyInjectorHandler.java:109)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.handlers.OptionsHandler.handleRequest(OptionsHandler.java:58)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.handlers.injectors.RequestContextInjectorHandler.handleRequest(RequestContextInjectorHandler.java:647)
    at org.restheart.handlers.PipedHttpHandler.next(PipedHttpHandler.java:136)
    at org.restheart.security.handlers.CORSHandler.handleRequest(CORSHandler.java:88)
    at org.restheart.handlers.RequestLoggerHandler.handleRequest(RequestLoggerHandler.java:87)
    at org.restheart.handlers.PipedHttpHandler.handleRequest(PipedHttpHandler.java:89)
    at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:94)
    at io.undertow.server.handlers.HttpContinueAcceptingHandler.handleRequest(HttpContinueAcceptingHandler.java:78)
    at org.restheart.handlers.ErrorHandler.handleRequest(ErrorHandler.java:69)
    at io.undertow.server.handlers.encoding.EncodingHandler.handleRequest(EncodingHandler.java:72)
    at org.restheart.handlers.GzipEncodingHandler.handleRequest(GzipEncodingHandler.java:74)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:802)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

We are using MongoDB 3.4 with driver 3.4.2. The above exception only occurs with RH3 but not with restheart 2.0.2 (which we previously used).

Any ideas on this?

Thanks, Tanja

ujibang commented 7 years ago

hi @grossmueller-espirit

this is a known bug fixed since version 3.0.1

https://softinstigate.atlassian.net/browse/RH-228

grossmueller-espirit commented 7 years ago

Hi @ujibang

thanks a lot for the information. I did not spot this when I was looking through your issues :-(