error calling AvatarLink: runtime error: invalid memory address or nil pointer dereference #10126

Closed
opened 2025-11-02 08:58:54 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @renothing on GitHub (Jan 18, 2023).

Description

homepage render 500 after upgraded to 1.18.1

2023/01/18 20:48:53 ...s/context/context.go:220:HTML() [D] [63c85b34] Template: user/dashboard/dashboard
2023/01/18 20:48:53 ...user/notification.go:46:func1() [I] [63c85b34] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) [1 1] - 1.62181ms
2023/01/18 20:48:53 ...ls/system/setting.go:122:GetSettings() [I] [63c85b34] [SQL] SELECT `id`, `setting_key`, `setting_value`, `version`, `created`, `updated` FROM `system_setting` WHERE setting_key IN (?) [picture.disable_gravatar] - 1.402161ms
2023/01/18 20:48:53 ...bce556200f/engine.go:1244:Get() [I] [63c85b34] [SQL] SELECT `id`, `uid`, `email`, `lower_email`, `is_activated`, `is_primary` FROM `email_address` WHERE `lower_email`=? LIMIT 1 [53425593+taylover2016@users.noreply.github.com] - 1.397ms
2023/01/18 20:48:53 ...ls/system/setting.go:122:GetSettings() [I] [63c85b34] [SQL] SELECT `id`, `setting_key`, `setting_value`, `version`, `created`, `updated` FROM `system_setting` WHERE setting_key IN (?) [picture.enable_federated_avatar] - 1.352367ms
2023/01/18 20:48:53 ...s/context/context.go:233:HTML() [E] [63c85b34] Render failed: template: user/dashboard/feeds:91:29: executing "user/dashboard/feeds" at <$push.AvatarLink>: error calling AvatarLink: runtime error: invalid memory address or nil pointer dereference
2023/01/18 20:48:53 ...s/context/context.go:220:HTML() [D] [63c85b34] Template: status/500

settings

[picture]
DISABLE_GRAVATAR   = true
AVATAR_UPLOAD_PATH = /data/gitea/avatars
[server]
OFFLINE_MODE       = true
DISABLE_ROUTER_LOG = true

Gitea Version

1.18.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image

Git Version

2.36.3

Operating System

docker

How are you running Gitea?

we use official docker image gitea/gitea

Database

MySQL

Originally created by @renothing on GitHub (Jan 18, 2023). ### Description homepage render 500 after upgraded to 1.18.1 ``` 2023/01/18 20:48:53 ...s/context/context.go:220:HTML() [D] [63c85b34] Template: user/dashboard/dashboard 2023/01/18 20:48:53 ...user/notification.go:46:func1() [I] [63c85b34] [SQL] SELECT count(*) FROM `notification` WHERE (user_id = ?) AND (status = ?) [1 1] - 1.62181ms 2023/01/18 20:48:53 ...ls/system/setting.go:122:GetSettings() [I] [63c85b34] [SQL] SELECT `id`, `setting_key`, `setting_value`, `version`, `created`, `updated` FROM `system_setting` WHERE setting_key IN (?) [picture.disable_gravatar] - 1.402161ms 2023/01/18 20:48:53 ...bce556200f/engine.go:1244:Get() [I] [63c85b34] [SQL] SELECT `id`, `uid`, `email`, `lower_email`, `is_activated`, `is_primary` FROM `email_address` WHERE `lower_email`=? LIMIT 1 [53425593+taylover2016@users.noreply.github.com] - 1.397ms 2023/01/18 20:48:53 ...ls/system/setting.go:122:GetSettings() [I] [63c85b34] [SQL] SELECT `id`, `setting_key`, `setting_value`, `version`, `created`, `updated` FROM `system_setting` WHERE setting_key IN (?) [picture.enable_federated_avatar] - 1.352367ms 2023/01/18 20:48:53 ...s/context/context.go:233:HTML() [E] [63c85b34] Render failed: template: user/dashboard/feeds:91:29: executing "user/dashboard/feeds" at <$push.AvatarLink>: error calling AvatarLink: runtime error: invalid memory address or nil pointer dereference 2023/01/18 20:48:53 ...s/context/context.go:220:HTML() [D] [63c85b34] Template: status/500 ``` settings ``` [picture] DISABLE_GRAVATAR = true AVATAR_UPLOAD_PATH = /data/gitea/avatars [server] OFFLINE_MODE = true DISABLE_ROUTER_LOG = true ``` ### Gitea Version 1.18.1 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![image](https://user-images.githubusercontent.com/261274/213289489-90ec5945-7769-425b-a4a1-9847a3d82c0d.png) ### Git Version 2.36.3 ### Operating System docker ### How are you running Gitea? we use official docker image `gitea/gitea` ### Database MySQL
GiteaMirror added the type/bug label 2025-11-02 08:58:54 -06:00
Author
Owner

@twisted-nematic57 commented on GitHub (Jan 19, 2023):

I'm using postgresql on arm64 ubuntu 22.04, everything's at latest version. Can reproduce the issue. This only occurs when the user is logged in, so users that are not logged in can still see the homepage just fine.

Everything else works fine AFAIK. Tested all tabs of the admin UI, and a few trivial Git actions on test repos.

Edit: It seems to fail when loading user icons that are from Git users that don't exist in the Gitea database. For example in my mirror of the Linux kernel source, Torvalds had his profile picture set on Github and that displayed fine in the mirror on 1.18. But now it fails because he's not registered as a user on my instance. It also attempts to display the profile pic of the person who committed recently on the homepage when I'm logged in so that also triggers the same error that the person who's posting got.

My profile picture displays fine in some places but fails in others. For example on my repository's homepage my committer profile pic is showing but when I click on the list of commits I get a slightly different nil pointer dereference error:
2023/01/18 16:26:29 ...s/context/context.go:233:HTML() [E] [63c88e35] Render failed: template: repo/commit_page:166:9: executing "repo/commit_page" at <avatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "mr-3">: error calling avatarByEmail: runtime error: invalid memory address or nil pointer dereference So I can clearly see it's something about a wrongfully dereferenced pointer that points to whatever avatarByEmail was looking for.

Rolling back to 1.18 for now.

@twisted-nematic57 commented on GitHub (Jan 19, 2023): I'm using postgresql on arm64 ubuntu 22.04, everything's at latest version. Can reproduce the issue. This only occurs when the user is logged in, so users that are not logged in can still see the homepage just fine. Everything else works fine AFAIK. Tested all tabs of the admin UI, and a few trivial Git actions on test repos. **Edit:** It seems to fail when loading user icons that are from Git users that don't exist in the Gitea database. For example in my mirror of the Linux kernel source, Torvalds had his profile picture set on Github and that displayed fine in the mirror on 1.18. But now it fails because he's not registered as a user on my instance. It also attempts to display the profile pic of the person who committed recently on the homepage when I'm logged in so that also triggers the same error that the person who's posting got. My profile picture displays fine in some places but fails in others. For example on my repository's homepage my committer profile pic is showing but when I click on the list of commits I get a slightly different `nil pointer dereference` error: `2023/01/18 16:26:29 ...s/context/context.go:233:HTML() [E] [63c88e35] Render failed: template: repo/commit_page:166:9: executing "repo/commit_page" at <avatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "mr-3">: error calling avatarByEmail: runtime error: invalid memory address or nil pointer dereference` So I can clearly see it's something about a wrongfully dereferenced pointer that points to whatever `avatarByEmail` was looking for. Rolling back to 1.18 for now.
Author
Owner

@crystalcommunication commented on GitHub (Jan 19, 2023):

Disabling Gravatar works around the problem

@crystalcommunication commented on GitHub (Jan 19, 2023): Disabling Gravatar works around the problem
Author
Owner

@twisted-nematic57 commented on GitHub (Jan 19, 2023):

Nope, disabling Gravatar does not fix the problem. Set DISABLE_GRAVATAR = true in [picture], still no avail.

@twisted-nematic57 commented on GitHub (Jan 19, 2023): Nope, disabling Gravatar does not fix the problem. Set `DISABLE_GRAVATAR = true` in `[picture]`, still no avail.
Author
Owner

@jolheiser commented on GitHub (Jan 19, 2023):

Since this is 1.18.x you will need to change it in the admin config page.

@jolheiser commented on GitHub (Jan 19, 2023): Since this is `1.18.x` you will need to change it in the admin config page.
Author
Owner

@twisted-nematic57 commented on GitHub (Jan 19, 2023):

Got it. Disabling Gravatar from the admin page worked and it didn't even need a restart to get fixed. Thanks!

However now I can't see external contributors' profile pics. This is just a temporary workaround.

@twisted-nematic57 commented on GitHub (Jan 19, 2023): Got it. Disabling Gravatar from the admin page worked and it didn't even need a restart to get fixed. Thanks! However now I can't see external contributors' profile pics. This is just a temporary workaround.
Author
Owner

@lunny commented on GitHub (Jan 19, 2023):

This has been fixed in coming v1.18.2.

@lunny commented on GitHub (Jan 19, 2023): This has been fixed in coming v1.18.2.
Author
Owner

@wolfogre commented on GitHub (Jan 19, 2023):

Fixed by #22479

@wolfogre commented on GitHub (Jan 19, 2023): Fixed by #22479
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10126