Our automated tests highlighted a minor change to the Machines API contract: when performing certain operations (delete, create machines etc.) on apps that don’t exist, we now receive a 401 instead of a 404.
Example request:
- DELETE /v1/apps/<app_name>
Earlier, if app_name
didn’t exist we’d get a 404 with “Could not find App” in the body. Now we seem to be getting a 401 back with no body.
Would it be possible to send a body back so that we know the 401 is not related to a bad token? Something like “This app either doesn’t exist or you don’t have access to it”.
I’d like to use this in our API client that does something like this:
def delete_app(app_name)
response = with_retries(max_tries: 3, rescue: [Net::OpenTimeout]) do
perform_request(Net::HTTP::Delete, "#{@api_url}/v1/apps/#{app_name}?force=true", headers: authorization_headers)
end
raise_if_response_is_50x!(response)
if response.code.eql?(202)
response.parsed_response
elsif response.code.eql?(404) && response.parsed_response["error"] =~ /Could not find App/
raise FlyIO::Errors::AppNotFound
else
raise "Error deleting app. Status: #{response.code}, Body: #{response.body}"
end
end