To reproduce, build a simple template to an endpoint that returns a 401 with json content type (such as apache marathon api with authentication). The template will be considered ready immediately.
The cause is https://github.com/criteo/consul-templaterb/blob/master/lib/consul/async/json_endpoint.rb#L205 where
enforce_json_200 && !(200..299).cover?(http.response_header.status) && http.response_header['Content-Type'] != 'application/json'
should probably be replaced by:
enforce_json_200 && !(200..299).cover?(http.response_header.status) || http.response_header['Content-Type'] != 'application/json'
The logic should be: if the response is not a 200 OK or is not advertize as json, then it's an error.
This bug leads to consider template as immediately ready.
To reproduce, build a simple template to an endpoint that returns a 401 with json content type (such as apache marathon api with authentication). The template will be considered ready immediately.
The cause is https://github.com/criteo/consul-templaterb/blob/master/lib/consul/async/json_endpoint.rb#L205 where
should probably be replaced by:
The logic should be: if the response is not a
200 OKor is not advertize as json, then it's an error.This bug leads to consider template as immediately ready.