languitar opened a new issue #8248:
URL: https://github.com/apache/pulsar/issues/8248


   **Describe the bug**
   
   When using the docker image as instructed in the manual for a local test, 
registering a schema for a new topic can result in an internal server error if 
the posted JSON file contains a `data` attribute. This is likely to happen by 
accident as the attribute `data` is used when GET-ing a schema for a topic 
instead of the field `schema` that is needed for the POST request
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Execute `docker run -it -p 6650:6650 -p 8080:8080 
apachepulsar/pulsar:2.6.1 bin/pulsar standalone`
   2. Create `/tmp/data.json` with the following content:
       ```json
       {
         "type": "AVRO",
         "data": "{\n \"name\": \"Example\",\n \"type\": \"record\",\n 
\"fields\": [\n  {\n   \"name\": \"a\",\n   \"type\": [\n    \"null\",\n    
\"string\"\n   ]\n  },\n  {\n   \"name\": \"b\",\n   \"type\": [\n    
\"null\",\n    \"int\"\n   ]\n  }\n ]\n}",
         "properties": {}
       }
       ```
   3. Execute `curl -d "@/tmp/data.json" -H "Content-Type: application/json" -X 
POST http://localhost:8080/admin/v2/schemas/public/default/my-topic/schema`
   
   This will result in the following response:
   ```html
   <html>
   <head>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
   <title>Error 500 Internal Server Error</title>
   </head>
   <body><h2>HTTP ERROR 500 Internal Server Error</h2>
   <table>
   
<tr><th>URI:</th><td>/admin/v2/schemas/public/default/my-topic/schema</td></tr>
   <tr><th>STATUS:</th><td>500</td></tr>
   <tr><th>MESSAGE:</th><td>Internal Server Error</td></tr>
   
<tr><th>SERVLET:</th><td>org.glassfish.jersey.servlet.ServletContainer-69efdfd9</td></tr>
   </table>
   <hr><a href="http://eclipse.org/jetty";>Powered by Jetty:// 
9.4.29.v20200521</a><hr/>
   
   </body>
   </html>
   ```
   
   And the server logs:
   ```
   14:03:22.726 [ForkJoinPool.commonPool-worker-9] INFO  
org.eclipse.jetty.server.RequestLog - 172.17.1.1 - - [13/Oct/2020:14:03:22 
+0000] "POST /admin/v2/schemas/public/default/my-topic/schema HTTP/1.1" 500 573 
"-" "curl/7.72.0" 20
   ```
   
   **Expected behavior**
   A descriptive error message is given that the provided data was invalid and 
the respective HTTP status code is used to indicate this.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to