Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We got NPE if the body is empty for post request in the request validation #144

Open
stevehu opened this issue Oct 30, 2020 · 2 comments
Open
Labels

Comments

@stevehu
Copy link
Contributor

stevehu commented Oct 30, 2020

The following error was captured from one of the users. As this is a known scenario, we need to add a check in the code to handler it with a proper error code. The graphql and hybrid hander will be addressed at the same time.

xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.428 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.431 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - path =/correlations
xhistory_1  | 21:22:23.431 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA DEBUG c.n.openapi.ApiNormalisedPath <init> - normalised = /correlations
xhistory_1  | 21:22:23.432 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA ERROR c.n.exception.ExceptionHandler handleRequest - Exception:
xhistory_1  | java.lang.NullPointerException: null
xhistory_1  | 	at com.networknt.openapi.RequestValidator.validateRequestBody(RequestValidator.java:126)
xhistory_1  | 	at com.networknt.openapi.RequestValidator.validateRequest(RequestValidator.java:93)
xhistory_1  | 	at com.networknt.openapi.ValidatorHandler.handleRequest(ValidatorHandler.java:84)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.audit.AuditHandler.next(AuditHandler.java:154)
xhistory_1  | 	at com.networknt.audit.AuditHandler.handleRequest(AuditHandler.java:143)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.body.BodyHandler.handleRequest(BodyHandler.java:123)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.openapi.OpenApiHandler.handleRequest(OpenApiHandler.java:108)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.correlation.CorrelationHandler.handleRequest(CorrelationHandler.java:77)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.traceability.TraceabilityHandler.handleRequest(TraceabilityHandler.java:66)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:208)
xhistory_1  | 	at com.networknt.handler.Handler.next(Handler.java:229)
xhistory_1  | 	at com.networknt.exception.ExceptionHandler.handleRequest(ExceptionHandler.java:76)
xhistory_1  | 	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370)
xhistory_1  | 	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
xhistory_1  | 	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558)
xhistory_1  | 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449)
xhistory_1  | 	at java.base/java.lang.Thread.run(Unknown Source)
xhistory_1  | 21:22:23.433 [XNIO-1 task-1]  i7RNA6CkQ_G4TcyF3Rm6PA ERROR c.networknt.handler.LightHttpHandler setExchangeStatus - {"statusCode":500,"code":"ERR10010","message":"RUNTIME_EXCEPTION","description":"Unexpected runtime exception","severity":"ERROR"} at com.networknt.handler.LightHttpHandler.setExchangeStatus(LightHttpHandler.java:67)
~~~~
@stevehu stevehu added the bug label Oct 30, 2020
@stevehu
Copy link
Contributor Author

stevehu commented Nov 3, 2020

Haven't got it reproduced with the unit test case yet. It looks like the error is triggered by a very specific combination.

@stevehu
Copy link
Contributor Author

stevehu commented Jan 8, 2021

What I have learned is that when the header content-type is plain/text, we can reproduce this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant