Consul crashes on empty body because args.Query is nil #3791
Labels
theme/api
Relating to the HTTP API interface
type/bug
Feature does not function as expected
type/crash
The issue description contains a golang panic and stack trace
Milestone
consul version
for both Client and ServerClient:
1.0.2
(also happens on 1.0.0)Server:
1.0.2
(also happens on 1.0.0)Operating system and Environment details
Tested on CentOS and Ubuntu. Also happens on Mac.
Description of the Issue (and unexpected/desired result)
Consul crashes when sent empty POST body to
/v1/query
via a client.Reproduction steps
Spin up a server and client
That should print out:
Then make POST request via curl:
Then the server should crash (and agent will complain and remove server):
Looking at the stacktrace, the problem seems to be that args.Query is nil and it's checking to see if
args.Query.ID
is not empty. ThepreparedQueryCreate
function is not json decoding unlessif req.ContentLength > 0 {
. Maybe it should be erroring if the body is empty?The text was updated successfully, but these errors were encountered: