[bug] Cannot approve User using admin-fe #560

Open
opened 2023-05-31 09:27:30 +00:00 by stefan230 · 4 comments
Contributor

Your setup

From source

Extra details

Ubuntu 22.04.2 LTS

Version

3.9.3-28-g9d7c877d (stable)

PostgreSQL version

14

What were you trying to do?

I am not 100% sure if this is an issue with admin-fe or with the backend, but it looks to be a backend-thing, so I decided to post on this repo.

The issue started a few weeks ago and backend-updates as well as reinstalling admin-fe did not help. If I remember correctly approval used to work correctly. Then I changed some settings in admin-fe namely I populated "Welome messages" under Settings -> Instance -> Welcome -> Direct Messages/E-Mail and then approval stopped working. I don't know in which way this related but I thought I might mention it anyway just to give a full picture. Here is the actual Problem discription:

I registered a new User. Email for confirming E-Mail Adress went fine. Confirming E-Mail worked. Using admin-FE I tried to approve a User and it failed. The User was not approved and the account cannot log in.

What did you expect to happen?

The User gets approved properly and can login normally.

What actually happened?

The approval fails and the newly registered User cannot login. Error states the account needs to be approved prior to logging in.

Logs

Mai 31 08:51:04 dungeon-homeserver mix[17427]: 08:51:04.057 request_id=F2QuS1Ekm-Nk31QAAfMi [error] Internal server error: %Protocol.UndefinedError{protocol: String.Chars, value: %Pleroma.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "AWD0nIXjqhvRedcSno", bio: "", raw_bio: nil, email: "<E-Mail-Adress>", name: "Test", nickname: "Test18", password_hash: "<here was a password-hash>", password: nil, password_confirmation: nil, keys: "<Private RSA-Key was here>", public_key: nil, ap_id: "https://ak.lightnovel-dungeon.de/users/Test18", avatar: %{}, local: true, follower_address: "https://ak.lightnovel-dungeon.de/users/Test18/followers", following_address: "https://ak.lightnovel-dungeon.de/users/Test18/following", featured_address: "https://ak.lightnovel-dungeon.de/users/Test18/collections/featured", search_rank: nil, search_type: nil, tags: [], last_refreshed_at: nil, last_digest_emailed_at: ~N[2023-05-31 08:50:10], banner: %{}, background: %{}, note_count: 0, follower_count: 0, following_count: 0, is_locked: false, is_confirmed: true, password_reset_pending: false, is_approved: true, registration_reason: "Ein TEstaccount", confirmation_token: nil, default_scope: "public", domain_blocks: [], is_active: true, no_rich_text: false, ap_enabled: false, is_moderator: false, is_admin: false, show_role: true, mastofe_settings: nil, uri: nil, hide_followers_count: false, hide_follows_count: false, hide_followers: false, hide_follows: false, ...}, description: ""}
Mai 31 08:51:04 dungeon-homeserver mix[17427]: 08:51:04.071 [error] #PID<0.3714.1> running Pleroma.Web.Endpoint (connection #PID<0.3713.1>, stream id 1) terminated
Mai 31 08:51:04 dungeon-homeserver mix[17427]: Server: ak.lightnovel-dungeon.de:80 (http)
Mai 31 08:51:04 dungeon-homeserver mix[17427]: Request: PATCH /api/v1/pleroma/admin/users/approve
Mai 31 08:51:04 dungeon-homeserver mix[17427]: ** (exit) an exception was raised:
Mai 31 08:51:04 dungeon-homeserver mix[17427]:     ** (Protocol.UndefinedError) protocol String.Chars not implemented for %Pleroma.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "AWD0nIXjqhvRedcSno", bio: "", raw_bio: nil, email: "test8@lightnovel-dungeon.de", name: "Test", nickname: "Test18", password_hash: "<here was a password-hash>", password: nil, password_confirmation: nil, keys: "<here was a private RSA-Key>", public_key: nil, ap_id: "https://ak.lightnovel-dungeon.de/users/Test18", avatar: %{}, local: true, follower_address: "https://ak.lightnovel-dungeon.de/users/Test18/followers", following_address: "https://ak.lightnovel-dungeon.de/users/Test18/following", featured_address: "https://ak.lightnovel-dungeon.de/users/Test18/collections/featured", search_rank: nil, search_type: nil, tags: [], last_refreshed_at: nil, last_digest_emailed_at: ~N[2023-05-31 08:50:10], banner: %{}, background: %{}, note_count: 0, follower_count: 0, following_count: 0, is_locked: false, is_confirmed: true, password_reset_pending: false, is_approved: true, registration_reason: "Ein TEstaccount", confirmation_token: nil, default_scope: "public", domain_blocks: [], is_active: true, no_rich_text: false, ap_enabled: false, is_moderator: false, is_admin: false, show_role: true, mastofe_settings: nil, uri: nil, hide_followers_count: false, hide_follows_count: false, hide_followers: false, hide_follows: false, hide_favorites: true, email_notifications: %{...}, ...} of type Pleroma.User (a struct). This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Decimal, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Hex.Solver.Assignment, Hex.Solver.Constraints.Empty, Hex.Solver.Constraints.Range, Hex.Solver.Constraints.Union, Hex.Solver.Incompatibility, Hex.Solver.PackageRange, Hex.Solver.Term, Integer, List, NaiveDateTime, OpenApiSpex.Cast.Error, Phoenix.LiveComponent.CID, Postgrex.Copy, Postgrex.Query, Regex, RemoteIp.Block, Time, URI, Version, Version.Requirement
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (elixir 1.14.3) lib/string/chars.ex:3: String.Chars.impl_for!/1
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (elixir 1.14.3) lib/string/chars.ex:22: String.Chars.to_string/1
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (stdlib 3.17) erl_eval.erl:685: :erl_eval.do_apply/6
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (stdlib 3.17) erl_eval.erl:446: :erl_eval.expr/5
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (stdlib 3.17) erl_eval.erl:123: :erl_eval.exprs/5
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (elixir 1.14.3) src/elixir.erl:294: :elixir.eval_forms/4
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (elixir 1.14.3) lib/module/parallel_checker.ex:110: Module.ParallelChecker.verify/1
Mai 31 08:51:04 dungeon-homeserver mix[17427]:         (elixir 1.14.3) lib/code.ex:829: Code.eval_quoted/3

Severity

I cannot use it as easily as I'd like

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details Ubuntu 22.04.2 LTS ### Version 3.9.3-28-g9d7c877d (stable) ### PostgreSQL version 14 ### What were you trying to do? I am not 100% sure if this is an issue with admin-fe or with the backend, but it looks to be a backend-thing, so I decided to post on this repo. The issue started a few weeks ago and backend-updates as well as reinstalling admin-fe did not help. If I remember correctly approval used to work correctly. Then I changed some settings in admin-fe namely I populated "Welome messages" under Settings -> Instance -> Welcome -> Direct Messages/E-Mail and then approval stopped working. I don't know in which way this related but I thought I might mention it anyway just to give a full picture. Here is the actual Problem discription: I registered a new User. Email for confirming E-Mail Adress went fine. Confirming E-Mail worked. Using admin-FE I tried to approve a User and it failed. The User was not approved and the account cannot log in. ### What did you expect to happen? The User gets approved properly and can login normally. ### What actually happened? The approval fails and the newly registered User cannot login. Error states the account needs to be approved prior to logging in. ### Logs ```shell Mai 31 08:51:04 dungeon-homeserver mix[17427]: 08:51:04.057 request_id=F2QuS1Ekm-Nk31QAAfMi [error] Internal server error: %Protocol.UndefinedError{protocol: String.Chars, value: %Pleroma.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "AWD0nIXjqhvRedcSno", bio: "", raw_bio: nil, email: "<E-Mail-Adress>", name: "Test", nickname: "Test18", password_hash: "<here was a password-hash>", password: nil, password_confirmation: nil, keys: "<Private RSA-Key was here>", public_key: nil, ap_id: "https://ak.lightnovel-dungeon.de/users/Test18", avatar: %{}, local: true, follower_address: "https://ak.lightnovel-dungeon.de/users/Test18/followers", following_address: "https://ak.lightnovel-dungeon.de/users/Test18/following", featured_address: "https://ak.lightnovel-dungeon.de/users/Test18/collections/featured", search_rank: nil, search_type: nil, tags: [], last_refreshed_at: nil, last_digest_emailed_at: ~N[2023-05-31 08:50:10], banner: %{}, background: %{}, note_count: 0, follower_count: 0, following_count: 0, is_locked: false, is_confirmed: true, password_reset_pending: false, is_approved: true, registration_reason: "Ein TEstaccount", confirmation_token: nil, default_scope: "public", domain_blocks: [], is_active: true, no_rich_text: false, ap_enabled: false, is_moderator: false, is_admin: false, show_role: true, mastofe_settings: nil, uri: nil, hide_followers_count: false, hide_follows_count: false, hide_followers: false, hide_follows: false, ...}, description: ""} Mai 31 08:51:04 dungeon-homeserver mix[17427]: 08:51:04.071 [error] #PID<0.3714.1> running Pleroma.Web.Endpoint (connection #PID<0.3713.1>, stream id 1) terminated Mai 31 08:51:04 dungeon-homeserver mix[17427]: Server: ak.lightnovel-dungeon.de:80 (http) Mai 31 08:51:04 dungeon-homeserver mix[17427]: Request: PATCH /api/v1/pleroma/admin/users/approve Mai 31 08:51:04 dungeon-homeserver mix[17427]: ** (exit) an exception was raised: Mai 31 08:51:04 dungeon-homeserver mix[17427]: ** (Protocol.UndefinedError) protocol String.Chars not implemented for %Pleroma.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "AWD0nIXjqhvRedcSno", bio: "", raw_bio: nil, email: "test8@lightnovel-dungeon.de", name: "Test", nickname: "Test18", password_hash: "<here was a password-hash>", password: nil, password_confirmation: nil, keys: "<here was a private RSA-Key>", public_key: nil, ap_id: "https://ak.lightnovel-dungeon.de/users/Test18", avatar: %{}, local: true, follower_address: "https://ak.lightnovel-dungeon.de/users/Test18/followers", following_address: "https://ak.lightnovel-dungeon.de/users/Test18/following", featured_address: "https://ak.lightnovel-dungeon.de/users/Test18/collections/featured", search_rank: nil, search_type: nil, tags: [], last_refreshed_at: nil, last_digest_emailed_at: ~N[2023-05-31 08:50:10], banner: %{}, background: %{}, note_count: 0, follower_count: 0, following_count: 0, is_locked: false, is_confirmed: true, password_reset_pending: false, is_approved: true, registration_reason: "Ein TEstaccount", confirmation_token: nil, default_scope: "public", domain_blocks: [], is_active: true, no_rich_text: false, ap_enabled: false, is_moderator: false, is_admin: false, show_role: true, mastofe_settings: nil, uri: nil, hide_followers_count: false, hide_follows_count: false, hide_followers: false, hide_follows: false, hide_favorites: true, email_notifications: %{...}, ...} of type Pleroma.User (a struct). This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Decimal, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Hex.Solver.Assignment, Hex.Solver.Constraints.Empty, Hex.Solver.Constraints.Range, Hex.Solver.Constraints.Union, Hex.Solver.Incompatibility, Hex.Solver.PackageRange, Hex.Solver.Term, Integer, List, NaiveDateTime, OpenApiSpex.Cast.Error, Phoenix.LiveComponent.CID, Postgrex.Copy, Postgrex.Query, Regex, RemoteIp.Block, Time, URI, Version, Version.Requirement Mai 31 08:51:04 dungeon-homeserver mix[17427]: (elixir 1.14.3) lib/string/chars.ex:3: String.Chars.impl_for!/1 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (elixir 1.14.3) lib/string/chars.ex:22: String.Chars.to_string/1 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (stdlib 3.17) erl_eval.erl:685: :erl_eval.do_apply/6 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (stdlib 3.17) erl_eval.erl:446: :erl_eval.expr/5 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (stdlib 3.17) erl_eval.erl:123: :erl_eval.exprs/5 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (elixir 1.14.3) src/elixir.erl:294: :elixir.eval_forms/4 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (elixir 1.14.3) lib/module/parallel_checker.ex:110: Module.ParallelChecker.verify/1 Mai 31 08:51:04 dungeon-homeserver mix[17427]: (elixir 1.14.3) lib/code.ex:829: Code.eval_quoted/3 ``` ### Severity I cannot use it as easily as I'd like ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
stefan230 added the
bug
label 2023-05-31 09:27:30 +00:00
Contributor

Been getting the same problem but my logs look a bit different

Jul 03 18:48:39 akko elixir[1173]: 18:48:39.299 request_id=F97Vj1Wl4-MieOABAB3D [error] Internal server error: %ArgumentError{message: "Unexpected tuple format, {\"Luna Nova\", \"\"} cannot be formatted into a Recipient.\n\nThe expected format is {name :: String.t() | nil, address :: String.t()}, where address cannot be empty.\n"}
Jul 03 18:48:39 akko elixir[1173]: 18:48:39.299 [error] #PID<0.8607881.0> running Pleroma.Web.Endpoint (connection #PID<0.8606730.0>, stream id 1) terminated
Jul 03 18:48:39 akko elixir[1173]: Server: akko.wtf:80 (http)
Jul 03 18:48:39 akko elixir[1173]: Request: PATCH /api/v1/pleroma/admin/users/approve
Jul 03 18:48:39 akko elixir[1173]: ** (exit) an exception was raised:
Jul 03 18:48:39 akko elixir[1173]:     ** (ArgumentError) Unexpected tuple format, {"Luna Nova", ""} cannot be formatted into a Recipient.
Jul 03 18:48:39 akko elixir[1173]: The expected format is {name :: String.t() | nil, address :: String.t()}, where address cannot be empty.
Jul 03 18:48:39 akko elixir[1173]:         (swoosh 1.14.4) lib/swoosh/email/recipient.ex:101: Swoosh.Email.Recipient.Tuple.format/1
Jul 03 18:48:39 akko elixir[1173]:         (swoosh 1.14.4) lib/swoosh/email.ex:210: Swoosh.Email.from/2
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/emails/user_email.ex:35: anonymous fn/2 in Pleroma.Emails.UserEmail.welcome/2
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/web/gettext.ex:115: Pleroma.Web.Gettext.with_locales_func/2
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user/welcome_email.ex:22: Pleroma.User.WelcomeEmail.send_email/1
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:923: Pleroma.User.maybe_send_welcome_email/1
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:882: Pleroma.User.post_register_action/1
Jul 03 18:48:39 akko elixir[1173]:         (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:1742: Pleroma.User.approve/1
Been getting the same problem but my logs look a bit different ``` Jul 03 18:48:39 akko elixir[1173]: 18:48:39.299 request_id=F97Vj1Wl4-MieOABAB3D [error] Internal server error: %ArgumentError{message: "Unexpected tuple format, {\"Luna Nova\", \"\"} cannot be formatted into a Recipient.\n\nThe expected format is {name :: String.t() | nil, address :: String.t()}, where address cannot be empty.\n"} Jul 03 18:48:39 akko elixir[1173]: 18:48:39.299 [error] #PID<0.8607881.0> running Pleroma.Web.Endpoint (connection #PID<0.8606730.0>, stream id 1) terminated Jul 03 18:48:39 akko elixir[1173]: Server: akko.wtf:80 (http) Jul 03 18:48:39 akko elixir[1173]: Request: PATCH /api/v1/pleroma/admin/users/approve Jul 03 18:48:39 akko elixir[1173]: ** (exit) an exception was raised: Jul 03 18:48:39 akko elixir[1173]: ** (ArgumentError) Unexpected tuple format, {"Luna Nova", ""} cannot be formatted into a Recipient. Jul 03 18:48:39 akko elixir[1173]: The expected format is {name :: String.t() | nil, address :: String.t()}, where address cannot be empty. Jul 03 18:48:39 akko elixir[1173]: (swoosh 1.14.4) lib/swoosh/email/recipient.ex:101: Swoosh.Email.Recipient.Tuple.format/1 Jul 03 18:48:39 akko elixir[1173]: (swoosh 1.14.4) lib/swoosh/email.ex:210: Swoosh.Email.from/2 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/emails/user_email.ex:35: anonymous fn/2 in Pleroma.Emails.UserEmail.welcome/2 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/web/gettext.ex:115: Pleroma.Web.Gettext.with_locales_func/2 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user/welcome_email.ex:22: Pleroma.User.WelcomeEmail.send_email/1 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:923: Pleroma.User.maybe_send_welcome_email/1 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:882: Pleroma.User.post_register_action/1 Jul 03 18:48:39 akko elixir[1173]: (pleroma 3.13.2-654-gd6ac8cb4-akko-wtf) lib/pleroma/user.ex:1742: Pleroma.User.approve/1 ```
Contributor

Can confirm it works after disabling the welcome message stuff and restarting akkoma.

Can confirm it works after disabling the welcome message stuff and restarting akkoma.
Member

EDIT2: am baka, skip this and read next message

original message (investigating the wrong thing) i’ve tried various register inputs to get the DB to contain an empty string as an email but without success. Sending `"email":""` or `"email":" "` etc in the registration API call, all lead to an explicit `NULL` in the DB and the welcome email seems to just be skipped.

Manually modifying the DB to contain an empty string as email for an unapproved user, leads to the same error as norm got though.

I guess the root bug here is somehow registrations leading to an empty string rather than NULL. But since such pending users already exist we prob should skip emails on empty strings too

This patch seems to suffice for the latter, but i’ll wait and see if we can get more insight into how it even came this far first:

diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex
index a7bcc03b6..cb68406b9 100644
--- a/lib/pleroma/emails/user_email.ex
+++ b/lib/pleroma/emails/user_email.ex
@@ -23,6 +23,7 @@ def render_body(email, template, assigns \\ %{}) do
     |> Phoenix.Swoosh.render_body(template, assigns)
   end
 
+  defp recipient("", _), do: nil
   defp recipient(email, nil), do: email
   defp recipient(email, name), do: {name, email}
   defp recipient(%User{} = user), do: recipient(user.email, user.name)

EDIT: or maybe not quite sufficeint (depending on adapter?), checking logs again it might have tried to send an email without any to field

**EDIT2**: am baka, skip this and read next message <details> <summary>original message (investigating the wrong thing)</summary> i’ve tried various register inputs to get the DB to contain an empty string as an email but without success. Sending `"email":""` or `"email":" "` etc in the registration API call, all lead to an explicit `NULL` in the DB and the welcome email seems to just be skipped. Manually modifying the DB to contain an empty string as email for an unapproved user, leads to the same error as norm got though. I guess the root bug here is _somehow_ registrations leading to an empty string rather than `NULL`. But since such pending users already exist we prob should skip emails on empty strings too This patch seems to suffice for the latter, but i’ll wait and see if we can get more insight into how it even came this far first: ```patch diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index a7bcc03b6..cb68406b9 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -23,6 +23,7 @@ def render_body(email, template, assigns \\ %{}) do |> Phoenix.Swoosh.render_body(template, assigns) end + defp recipient("", _), do: nil defp recipient(email, nil), do: email defp recipient(email, name), do: {name, email} defp recipient(%User{} = user), do: recipient(user.email, user.name) ``` **EDIT**: or maybe not quite sufficeint (depending on adapter?), checking logs again it might have tried to send an email without any `to` field </details>
Member

disregard everything i wrote before, i just didn’t notice the empty address was the sender rather than receiver
Should be easily fixed by properly specifying the address in the config

The original issue reported by stefan230 occurs in a completely different place and is probably something else. Unfortunately the backtrace doesn't even (go back far enough to) contain any akkoma source code, making it hard to guess what/where things went wrong

disregard everything i wrote before, i just didn’t notice the empty address was the _sender_ rather than _receiver_ Should be easily fixed by properly specifying the address in the config The original issue reported by stefan230 occurs in a completely different place and is probably something else. Unfortunately the backtrace doesn't even (go back far enough to) contain any akkoma source code, making it hard to guess what/where things went wrong
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#560
No description provided.