trace-server-protocol icon indicating copy to clipboard operation
trace-server-protocol copied to clipboard

Request body of POST to traces and experiments missing "parameters"

Open awendelin-work opened this issue 1 year ago • 1 comments

There appears to be an inconsistency between the reference trace-server and the openapi specification. The examples below are done using trace-compass-incubator built from commit 4b14d71637df2cedecd48d4287851315418a2d31.

According to the openapi specification, the POST to import a trace is supposed to look like:

curl -i --header "Content-Type: application/json" --header "Accept: application/json" --request POST --data '{"uri":"/home/<redacted>/builds/tsp-python-client/tracecompass-test-traces/ctf/src/main/resources/context-switches/context-switches-ust"}' http://localhost:8080/tsp/api/traces

But that gives back a response like:

HTTP/1.1 400 Bad Request
Server: Jetty(12.0.9)
Date: Fri, 19 Jul 2024 14:26:12 GMT
Content-Type: text/plain
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
Vary: Accept-Encoding
Content-Length: 443

Unrecognized field "uri" (class org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters), not marked as ignorable (2 known properties: "parameters", "filters"])
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 9] (through reference chain: org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters["uri"])

What you actually need to send is:

curl -i --header "Content-Type: application/json" --header "Accept: application/json" --request POST --data '{"parameters": {"uri":"/home/<redacted>/builds/tsp-python-client/tracecompass-test-traces/ctf/src/main/resources/context-switches/context-switches-ust"}}' http://localhost:8080/tsp/api/traces

Which returns:

HTTP/1.1 200 OK
Server: Jetty(12.0.9)
Date: Fri, 19 Jul 2024 14:28:05 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: origin, content-type, accept, authorization
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
Vary: Accept-Encoding
Content-Length: 268

{"name":"context-switches-ust","path":"/home/<redacted>/builds/tsp-python-client/tracecompass-test-traces/ctf/src/main/resources/context-switches/context-switches-ust","UUID":"8f0b3517-e95f-31c5-ba70-ee889f8883c0","nbEvents":0,"start":0,"end":0,"indexingStatus":"CLOSED"}

The openapi specification is missing the wrapping "parameters" object in the request body schema that the server requires.

The same applies to opening an experiment where this fails with a 400:

curl -i --header "Content-Type: application/json" --header "Accept: application/json" --request POST --data '{"traces":["8f0b3517-e95f-31c5-ba70-ee889f8883c0"], "name": "broken"}' http://localhost:8080/tsp/api/experiments

But this works:

curl -i --header "Content-Type: application/json" --header "Accept: application/json" --request POST --data '{"parameters": {"traces":["8f0b3517-e95f-31c5-ba70-ee889f8883c0"], "name": "broken"}}' http://localhost:8080/tsp/api/experiments

So there are two main issues with the specification here:

  1. The request body schema for "putTrace" aka POST to /traces is missing "parameters"
  2. The request body schema for "postExperiment" aka POST to /experiments is missing "parameters"

awendelin-work avatar Jul 19 '24 14:07 awendelin-work