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

POST JSON Rule definition can result in NPE #643

Closed
andrewazores opened this issue Aug 12, 2021 · 0 comments · Fixed by #648
Closed

POST JSON Rule definition can result in NPE #643

andrewazores opened this issue Aug 12, 2021 · 0 comments · Fixed by #648
Assignees
Labels
bug Something isn't working

Comments

@andrewazores
Copy link
Member

$ https -v --json POST :8181/api/v2/rules name:foo matchExpression="target.annotations.cryostat['JAVA_MAIN']=='demoApp'" eventSpecifier="template=Continuous,type=TARGET"
POST /api/v2/rules HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 127
Content-Type: application/json
Host: localhost:8181
User-Agent: HTTPie/2.4.0
name: foo

{
    "eventSpecifier": "template=Continuous,type=TARGET",
    "matchExpression": "target.annotations.cryostat['JAVA_MAIN']=='demoApp'"
}


HTTP/1.1 500 Internal Server Error
content-encoding: gzip
content-length: 103
content-type: application/json

{
    "data": {
        "reason": null
    },
    "meta": {
        "status": "Internal Server Error",
        "type": "text/plain"
    }
}

I sent a POST /api/v2/rules and incorrectly formatted my request, so the name key was not included in the JSON body (instead, it was sent as an HTTP header). This resulted in an HTTP 500:

Aug 12, 2021 7:28:28 PM io.cryostat.core.log.Logger error
SEVERE: Exception thrown
io.cryostat.net.web.http.api.v2.ApiException: Internal Server Error
Caused by: java.lang.NullPointerException
	at io.cryostat.rules.Rule$Builder.from(Rule.java:234)
	at io.cryostat.util.RuleDeserializer.deserialize(RuleDeserializer.java:58)
	at io.cryostat.util.RuleDeserializer.deserialize(RuleDeserializer.java:51)
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at io.cryostat.net.web.http.api.v2.RulesPostHandler.handle(RulesPostHandler.java:144)
	at io.cryostat.net.web.http.api.v2.AbstractV2RequestHandler.handle(AbstractV2RequestHandler.java:114)
	at io.cryostat.net.web.http.api.v2.AbstractV2RequestHandler.handle(AbstractV2RequestHandler.java:68)
	at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
	at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

Aug 12, 2021 7:28:28 PM io.cryostat.core.log.Logger info
INFO: (10.0.2.100:60442): POST /api/v2/rules 500 4ms

This should have instead been a 400.

@andrewazores andrewazores added the bug Something isn't working label Aug 12, 2021
@andrewazores andrewazores self-assigned this Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant