Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(channels): log the resolved route for inbound events (#11082)

Danila Katalshov48e9c283b753
diff --git a/server/internal/integrations/channel/engine/router.go b/server/internal/integrations/channel/engine/router.go
index a8a1153969..8a7c81df88 100644
--- a/server/internal/integrations/channel/engine/router.go
+++ b/server/internal/integrations/channel/engine/router.go
@@ -281,6 +281,9 @@ func (r *Router) Handle(ctx context.Context, msg channel.InboundMessage) error {
"event_id", msg.EventID,
"outcome", string(res.Outcome),
"drop_reason", string(res.DropReason),
+ "installation_id", util.UUIDToString(res.InstallationID),
+ "chat_session_id", util.UUIDToString(res.ChatSessionID),
+ "route_revision", res.ChannelRouteRevision,
)
// Typing indicator on ingest, detached so the reaction HTTP call never
diff --git a/server/internal/integrations/channel/engine/router_test.go b/server/internal/integrations/channel/engine/router_test.go
index 81ff200469..1b809a2d62 100644
--- a/server/internal/integrations/channel/engine/router_test.go
+++ b/server/internal/integrations/channel/engine/router_test.go
@@ -3,6 +3,7 @@ package engine
import (
"bytes"
"context"
+ "encoding/json"
"errors"
"log/slog"
"sync"
@@ -15,6 +16,7 @@ import (
"github.com/multica-ai/multica/server/internal/integrations/channel"
"github.com/multica-ai/multica/server/internal/service"
+ "github.com/multica-ai/multica/server/internal/util"
db "github.com/multica-ai/multica/server/pkg/db/generated"
)
@@ -548,6 +550,47 @@ func newHarness(t *testing.T) *harness {
return h
}
+func TestRouterLogsResolvedChannelRoute(t *testing.T) {
+ h := newHarness(t)
+ var logs bytes.Buffer
+ h.router.logger = slog.New(slog.NewJSONHandler(&logs, &slog.HandlerOptions{Level: slog.LevelDebug}))
+ message := p2pMessage(t)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ if err := h.router.Handle(ctx, message); err != nil {
+ t.Fatal(err)
+ }
+ if !h.router.Drain(ctx) {
+ t.Fatal("router drain timed out")
+ }
+
+ decoder := json.NewDecoder(&logs)
+ for decoder.More() {
+ var entry map[string]any
+ if err := decoder.Decode(&entry); err != nil {
+ t.Fatal(err)
+ }
+ if entry["msg"] != "channel router: dispatch outcome" {
+ continue
+ }
+ for field, want := range map[string]any{
+ "event_id": message.EventID,
+ "installation_id": util.UUIDToString(h.inst.inst.ID),
+ "chat_session_id": util.UUIDToString(h.binder.ensureID),
+ "route_revision": float64(h.binder.appendResult.RouteRevision),
+ } {
+ if entry[field] != want {
+ t.Errorf("%s = %v, want %v", field, entry[field], want)
+ }
+ }
+ if _, logged := entry["text"]; logged {
+ t.Fatal("dispatch log includes message text")
+ }
+ return
+ }
+ t.Fatal("missing dispatch outcome log")
+}
+
func TestRouter_NoResolverSet_ReturnsError(t *testing.T) {
h := newHarness(t)
msg := p2pMessage(t)