From: Anton Khorev Date: Sat, 19 Aug 2023 17:22:19 +0000 (+0300) Subject: Respond with plaintext when user not found in changeset query X-Git-Tag: live~1121^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0bd5838f5100c98ece1229b40e2e722bc24e643b?hp=406d90c5c8da5633324bb1d28d7a2103a61c95e4 Respond with plaintext when user not found in changeset query The response used to be of type xml with empty body, which is not valid xml. --- diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 84f1ccdb5..a3dff4f1c 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -307,7 +307,7 @@ module Api # user input checking, we don't have any UIDs < 1 raise OSM::APIBadUserInput, "invalid user ID" if user.to_i < 1 - u = User.find(user.to_i) + u = User.find_by(:id => user.to_i) else u = User.find_by(:display_name => name) end diff --git a/test/controllers/api/changesets_controller_test.rb b/test/controllers/api/changesets_controller_test.rb index fd1940d6b..d4656a5ea 100644 --- a/test/controllers/api/changesets_controller_test.rb +++ b/test/controllers/api/changesets_controller_test.rb @@ -1863,8 +1863,10 @@ module Api # not found when looking for changesets of non-existing users get changesets_path(:user => User.maximum(:id) + 1) assert_response :not_found + assert_equal "text/plain", @response.media_type get changesets_path(:display_name => " ") assert_response :not_found + assert_equal "text/plain", @response.media_type # can't get changesets of user 1 without authenticating get changesets_path(:user => private_user.id)