Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/_synapse/admin/v1/send_server_notice 500s on use. #3502

Open
TruncatedDinoSour opened this issue Jan 16, 2025 · 0 comments
Open

/_synapse/admin/v1/send_server_notice 500s on use. #3502

TruncatedDinoSour opened this issue Jan 16, 2025 · 0 comments

Comments

@TruncatedDinoSour
Copy link

TruncatedDinoSour commented Jan 16, 2025

Background information

  • Dendrite version or git SHA: 0.14.1+40bef6a
  • SQLite3 or Postgres?: Postgres
  • Running in Docker?: Unprivileged user
  • go version: go version go1.23.4 linux/amd64
  • Client used (if applicable): Python requests

Description

  • What is the problem: When making a standard request to the send_server_notice admin API endpoint, when server notices are enabled as well as profile picture is set (unsure if the profile picture one is related), the API returns an internal error.
  • Who is affected: The administrator.
  • How is this bug manifesting: By returning error responses as well as putting errors in logs.
  • When did this first appear: When I first used this API, in v0.14.1.

Steps to reproduce

  • Enable server notices:
  server_notices:
    enabled: true
    # The local part, display name and avatar URL (as a mxc:// URL) for the user that
    # will send the server notices. These are visible to all users on the deployment.
    local_part: "_server"
    display_name: "Ari-web -> Matrix (notifications)"
    avatar_url: "https://matrix.ari.lt/_matrix/media/r0/download/ari.lt/3c37dc4c292330bb27f05794190cf87b10715473c73c0d8d582babad22d44f9f"
    # The room name to be used when sending server notices. This room name will
    # appear in user clients.
    room_name: "Ari-web -> Matrix (notifications)"

Note: I notice I made it an https:// URL for the avatar. But this might still be a problem regardless. Fixing this does not fix the problem (tested with mxc://ari.lt/3c37dc4c292330bb27f05794190cf87b10715473c73c0d8d582babad22d44f9f).

  • Make a standard request:
    pprint(
        requests.post(
            f"http://127.0.0.1:8008/_synapse/admin/v1/send_server_notice",
            json={
                "user_id": "@ari:ari.lt",
                "content": {
                    "msgtype": "m.text",
                    "body": msg,
                    "format": "org.matrix.custom.html",
                    "formatted_body": markdown.markdown(msg),
                },
            },
            headers={"Authorization": f"Bearer {token}"},
        ).json()
    )
  • Get an error response ({'message': 'Internal Server Error'}) as well as the following log:
goroutine 372895 [running]:
runtime/debug.Stack()
        /usr/lib/go/src/runtime/debug/stack.go:26 +0x5e
github.com/element-hq/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.Protect.func3.1()
        /home/ari/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:98 +0x13c
panic({0x16ffbe0?, 0x26cf940?})
        /usr/lib/go/src/runtime/panic.go:785 +0x132
github.com/element-hq/dendrite/internal/httputil.MakeAuthAPI.func1.1()
        /home/ari/Src/dendrite/internal/httputil/httpapi.go:94 +0x4a
panic({0x16ffbe0?, 0x26cf940?})
        /usr/lib/go/src/runtime/panic.go:785 +0x132
github.com/matrix-org/util.ErrorResponse(...)
        /home/ari/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:52
github.com/element-hq/dendrite/clientapi/routing.SendServerNotice(0xc0252eaf00, 0xc0001909c8, 0xc000190a68, {0x7f106167a6f8, 0xc0004ee090}, {0x7f106167a580, 0xc00664cc60}, {0x1c02180, 0xc00a37a3a8}, 0xc00c0c2510, ...)
        /home/ari/Src/dendrite/clientapi/routing/server_notices.go:103 +0x600
github.com/element-hq/dendrite/clientapi/routing.Setup.func15(0xc0252eaf00, 0xc00c0c2510)
        /home/ari/Src/dendrite/clientapi/routing/routing.go:281 +0x138
github.com/element-hq/dendrite/internal/httputil.MakeAuthAPI.func1(0xc022d91b80)
        /home/ari/Src/dendrite/internal/httputil/httpapi.go:111 +0x58d
github.com/matrix-org/util.(*jsonRequestHandlerWrapper).OnIncomingRequest(0xc022d91a40?, 0x47335d?)
        /home/ari/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:79 +0x19
github.com/element-hq/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.func2({0x1bfd4f8, 0xc01c5c2d20}, 0x0?)
        /home/ari/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:141 +0xaa
github.com/element-hq/dendrite/internal/httputil.MakeExternalAPI.MakeJSONAPI.Protect.func3({0x1bfd4f8?, 0xc01c5c2d20?}, 0x192fee4?)
        /home/ari/go/pkg/mod/github.com/matrix-org/util@v0.0.0-20221111132719-399730281e66/json.go:103 +0x57
net/http.HandlerFunc.ServeHTTP(...)
        /usr/lib/go/src/net/http/server.go:2220
github.com/element-hq/dendrite/internal/httputil.MakeExternalAPI.func1({0x1bfd4f8?, 0xc01c5c2d20?}, 0xc022d91900)
        /home/ari/Src/dendrite/internal/httputil/httpapi.go:194 +0x3b2
net/http.HandlerFunc.ServeHTTP(0xc022d917c0?, {0x1bfd4f8?, 0xc01c5c2d20?}, 0x0?)
        /usr/lib/go/src/net/http/server.go:2220 +0x29
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0000ed5c0, {0x1bfd4f8, 0xc01c5c2d20}, 0xc022d91680)
        /home/ari/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1e2
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00bd5e9c0, {0x1bfd4f8, 0xc01c5c2d20}, 0xc022d91400)
        /home/ari/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1e2
net/http.serverHandler.ServeHTTP({0x1bf9860?}, {0x1bfd4f8?, 0xc01c5c2d20?}, 0x6?)
        /usr/lib/go/src/net/http/server.go:3210 +0x8e
net/http.(*conn).serve(0xc00c0c2360, {0x1c00160, 0xc00bfb7470})
        /usr/lib/go/src/net/http/server.go:2092 +0x5d0
created by net/http.(*Server).Serve in goroutine 2383
        /usr/lib/go/src/net/http/server.go:3360 +0x485

I.e. runtime error: invalid memory address or nil pointer dereference

Note: Dendrite is built on a separate machine it is running on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant