When doing a query to the decision, I've changed subject_id to the invalid one. Greenwave returned 502, but according to documentation ( https://docs.pagure.org/greenwave/api.html#http-rest-api ), there could be only 200 or 400 status codes.
curl -k -H "Content-Type: application/json" --data ' > > { "decision_context": "osci_compose_gate_modules", "product_version": "rhel-8", "subject_type": "redhat-module", "subject_identifier": "httpd-2.4-132190206142837.9edba152" } > ' https://greenwave.engineering.redhat.com/api/v1.0/decision -v * Trying 10.0.18.68... .... SSL bla-bla-bla skipped .... > POST /api/v1.0/decision HTTP/1.1 > Host: greenwave.engineering.redhat.com > User-Agent: curl/7.59.0 > Accept: */* > Content-Type: application/json > Content-Length: 176 > * upload completely sent off: 176 out of 176 bytes < HTTP/1.1 502 BAD GATEWAY < Server: gunicorn/19.7.1 < Date: Tue, 02 Apr 2019 11:24:57 GMT < Connection: close < Content-Type: application/json < Access-Control-Allow-Origin: * < Access-Control-Allow-Headers: Content-Type < Access-Control-Allow-Method: POST, OPTIONS < Content-Length: 143 < { "message": "Failed to find Koji build for \"httpd-2.4-132190206142837.9edba152\" at \"https://brewhub.engineering.redhat.com/brewhub/\"" } * Closing connection 0 * TLSv1.2 (OUT), TLS alert, Client hello (1):
Yeah we should update the doc. Do you need help with the error too, or is it clear to you?
I don't think Greenwave should be returning 502 in this case. We should fix that :)
502 (https://http.cat/502) gets returned by Greenwave when we cannot find the koji/brew build when checking the remoterules. Don't you think Bad Gateway is right here?
I'd rather use 404, but I really don't care about exact code. It could be any, but it should be mentioned in the documentation.
Usually 5xx errors are reserved for server errors. This is not the case here. 404 seems fine to me as well.
+1 502 is incorrect and misleading here. 5xx errors are supposed to mean 'you made a valid request but the server screwed up somehow'. "The server could not do what you asked because of some issue with the request itself" should always be a 4xx. 404 looks correct here.
502
Note that the definition of 502 is "The server was acting as a gateway or proxy and received an invalid response from the upstream server." (emphasis added). "invalid" there is very important. Greenwave is not receiving an invalid response from Koji here - it's receiving a perfectly valid response which says "that Koji build doesn't exist". You'd expect to get a 502 if the proxy just couldn't reach the upstream server at all or the upstream server gave it an entirely garbage response or a 5xx error of its own - that's the case I expect to be in if I see a 502.
Great. Let's change that to 404 and update the doc.
Commit d2e3f234 fixes this issue