Skip to content

Panic: index out of range [-1] in IRCError.Error() when logging typing-send failure #3

Description

@rlue

Warning

AI slop ahead. I've never worked with go (or matrix or irc for that matter) and relied on Claude to understand the error logs that were coming up on my server. I've read through the report in its entirety a couple times and trimmed it down here and there, but the text itself is more or less verbatim from Claude.

That being said, I believe the report is correct, complete, and free of unnecessary detail or confidently-wrong assumptions/misunderstandings.

Issue

Relaying an m.typing event to certain IRC channels fails, and the bridge then panics while formatting the error for the log. (*IRCError).Error() indexes out of range at pkg/connector/ircrequest.go:61.

Because the panic occurs in the error's own stringifier, the underlying IRC failure is never logged — the message that would explain the root cause is exactly the one that crashes. This makes the primary failure undiagnosable from logs.

To Reproduce

  1. Make sure "Send typing notifications" is enabled in your client
  2. Log into Libera.Chat via the bridge
  3. Join libera #zig
  4. Type in the resulting Matrix portal room (to send an m.typing event)
  5. Panic on every typing event in that room

Logs

2026-09-14T16:11:39.632Z ERR Event handling panicked error="runtime error: index out of range [-1]"
  action="handle matrix event" event_id= event_loop_index=57 event_type=m.typing
  portal_id=libera:#zig portal_mxid=!nVXsbCWjxUF5X7K2zi:example.org

goroutine 48862 [running]:
runtime/debug.Stack()
maunium.net/go/mautrix/bridgev2.(*Portal).handleSingleEvent.func1()
      maunium.net/go/mautrix@v0.28.0/bridgev2/portal.go:564 +0x14c
panic({0xe0c2a0?, 0x323cd4a84120?})
go.mau.fi/mautrix-irc/pkg/connector.(*IRCError).Error(0x323cd496e038)
      /builds/mautrix/irc/pkg/connector/ircrequest.go:61 +0xac          <-- panic here
github.com/rs/zerolog.(*Event).AnErr(...)  zerolog@v1.35.1/event.go:435
github.com/rs/zerolog.(*Event).Err(...)    zerolog@v1.35.1/event.go:482
github.com/rs/zerolog.(*Logger).Err(...)   zerolog@v1.35.1/log.go:379
maunium.net/go/mautrix/bridgev2.(*Portal).sendTypings(...)
      maunium.net/go/mautrix@v0.28.0/bridgev2/portal.go:1045 +0x35c
maunium.net/go/mautrix/bridgev2.(*Portal).handleMatrixTyping(...)
      maunium.net/go/mautrix@v0.28.0/bridgev2/portal.go:1000 +0x188

Analysis

sendTypings receives an error from the connector and logs it via zerolog.Err(), which calls Error() on the value. IRCError.Error() then panics.

index out of range [-1] is the signature of x[len(x)-1] against an empty slice — most likely reading the last parameter of an IRC response that arrived with zero parameters. A bounds check would both fix the panic and surface the real error.

Impact

Non-fatal — bridgev2's per-event recover handler catches it, and the bridge stays healthy (NRestarts=0). Effects are lost typing notifications in the affected channel and log noise. Messages are unaffected.

Note

A comparable typing failure in another channel logged cleanly, which supports the empty-parameter theory:

ERR Failed to bridge Matrix typing event error="415: Cannot send message to channel (+R) - you need to be logged into your NickServ account"

Checklist

  • This is an actual bug, not just a setup issue (see the troubleshooting docs or ask in the Matrix room for setup help).
  • I am certain that sufficient information is included. Ask in the Matrix room first if not.
  • The bug is still present on the main branch. The !irc version command output is: v25.11+dev.dc12cc74 (Tue, 19 May 2026 17:15:00 UTC)

Environment

  • mautrix-irc: v25.11+dev.dc12cc74, built_at=2026-05-19T17:15:00Z, go1.26.3 * Image digest: sha256:f1b0dc03fd14640a97cfa8e3a1afa055613f5e892fa0998a94755b15094502ad (dock.mau.dev/mautrix/irc:latest, current as of 2026-09-14)
  • mautrix-go: v0.28.0
  • Homeserver: tuwunel (conduwuit fork), docker.io/jevolk/tuwunel:latest * Platform: Linux 7.1.10 aarch64 (Asahi, Apple Silicon)
  • Deployment: rootless podman 5.8.6 quadlet, NixOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions