Redmine - Defect #37157
Internal server error when trying to retrieve AnonymousUser's information via Users API
2022-05-25 02:59 - Go MAEDA

ステータス:

Closed

開始日:

優先度:

Normal期日:担当者:

Marius B

カテゴリ:

REST API

対象バージョン:5.0.2

Resolution:

FixedLTEANU

進捗率:

0%

予定工数:

0.00時間Affected version:

5.0.0

説明
Users API raises an exception when it attempts to generate an avatar URL for AnonymousUser. This was originally reported in#36303#note-8 by Alex Moroz.
Started GET "/users/6.json" for 127.0.0.1 at 2022-05-25 09:41:36 +0900
Processing by UsersController#show as JSON
Parameters: {"id"=>"6"}.
(snip).
Rendering users/show.api.rsb
Rendered users/show.api.rsb (Duration: 0.5ms ¦ Allocations: 200)
Completed 500 Internal Server Error in 15ms (ActiveRecord: 1.9ms ¦ Allocations:7193)

ActionView::Template::Error (no implicit conversion of nil into String):
9:
api.updated̲on @user.updated̲on10:
api.last̲login̲on@user.last̲login̲on11:
api.passwd̲changed̲on @user.passwd̲changed̲on
12:
api.avatar̲url gravatar̲url(@user.mail, {rating: nil, size: nil, default: Setting.gravatar̲default}) if Setting.grav?
13:
api.twofa̲scheme@user.twofa̲scheme if User.current.admin? ¦¦ (User.current == @user)
14:
api.api̲key@user.api̲key if User.current.admin? ¦¦ (User.current == @user)
15:
api.status@user.status if User.current.admin?
lib/plugins/gravatar/lib/gravatar.rb:68:in ̀digest'
lib/plugins/gravatar/lib/gravatar.rb:68:in ̀hexdigest'
lib/plugins/gravatar/lib/gravatar.rb:68:in ̀gravatar̲url'app/views/users/show.api.rsb:12
lib/redmine/views/builders/structure.rb:73:in ̀method̲missing'app/views/users/show.api.rsb:1
lib/redmine/views/builders.rb:38:in ̀for'app/views/users/show.api.rsb:1
lib/redmine/sudo̲mode.rb:61:in ̀sudo̲mode'
関連するチケット:
関連している Redmine - Feature #36303: Include avatar URL in Us...

Closed

関係しているリビジョン
リビジョン 21606 - 2022-05-28 00:14 - Marius B

LTEANUFix internal server error when trying to retrieve AnonymousUser's information via Users API (#37157).
Patch by Yuichi HARADA.
リビジョン 21615 - 2022-05-28 11:55 - Marius B

LTEANU

Merged r21606 to 5.0-stable (#37157).

履歴#1 - 2022-05-25 03:06 - Go MAEDA- 関連している Feature #36303: Include avatar URL in Users API を追加

2024-09-27

1/2

#2 - 2022-05-26 06:49 - Yuichi HARADA- ファイル 37157.patch を追加
Users API was raised with an exception because AnonymousUser has no email address set.
The following patch will solve the problem.

diff --git a/app/views/users/show.api.rsb b/app/views/users/show.api.rsb
index f6a323265a..d84be914ec 100644--- a/app/views/users/show.api.rsb+++ b/app/views/users/show.api.rsb@@ -9,7 +9,7 @@api.user do
api.updated̲on @user.updated̲on
api.last̲login̲on@user.last̲login̲on
api.passwd̲changed̲on @user.passwd̲changed̲on
api.avatar̲url gravatar̲url(@user.mail, {rating: nil, size: nil, default: Setting.gravatar̲default}) if Setting.gravatar̲enabled?
+api.avatar̲url gravatar̲url(@user.mail, {rating: nil, size: nil, default: Setting.gravatar̲default}) if @user.mail && Setting.gravatar̲enabled
api.twofa̲scheme@user.twofa̲scheme if User.current.admin? ¦¦ (User.current == @user)
api.api̲key@user.api̲key if User.current.admin? ¦¦ (User.current == @user)
api.status@user.status if User.current.admin?
#3 - 2022-05-27 20:54 - Marius B

LTEANU- 対象バージョン を 5.0.2 にセット
#4 - 2022-05-28 11:56 - Marius B

LTEANU- ステータス を New から Closed に変更- 担当者 を Marius B

LTEANU にセット

- Resolution を Fixed にセット
Fixed committed, thanks!

ファイル
37157.patch

2024-09-27

1.91 KB

2022-05-26

Yuichi HARADA

2/2