{"record":{"id":"1b812f2d3efa2b72","repo":"sipeed/picoclaw","slug":"error-creating-channel-manager-w","errorCode":null,"errorMessage":"error creating channel manager: %w","messagePattern":"error creating channel manager: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gateway/gateway.go","lineNumber":464,"sourceCode":"\t\tEnabled:  cfg.Tools.MediaCleanup.Enabled,\n\t\tMaxAge:   time.Duration(cfg.Tools.MediaCleanup.MaxAge) * time.Minute,\n\t\tInterval: time.Duration(cfg.Tools.MediaCleanup.Interval) * time.Minute,\n\t})\n\tif fms, ok := runningServices.MediaStore.(*media.FileMediaStore); ok {\n\t\tfms.Start()\n\t}\n\n\trunningServices.ChannelManager, err = channels.NewManager(\n\t\tcfg,\n\t\tmsgBus,\n\t\trunningServices.MediaStore,\n\t\tchannels.WithRuntimeEvents(agentLoop.RuntimeEventBus()),\n\t)\n\tif err != nil {\n\t\tif fms, ok := runningServices.MediaStore.(*media.FileMediaStore); ok {\n\t\t\tfms.Stop()\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error creating channel manager: %w\", err)\n\t}\n\n\tagentLoop.SetChannelManager(runningServices.ChannelManager)\n\tagentLoop.SetMediaStore(runningServices.MediaStore)\n\n\ttranscriber := asr.DetectTranscriber(cfg)\n\tif transcriber != nil {\n\t\tagentLoop.SetTranscriber(transcriber)\n\t\tlogger.InfoCF(\"voice\", \"Transcription enabled (agent-level)\", map[string]any{\"provider\": transcriber.Name()})\n\t}\n\n\tttsAvailable := tts.DetectTTS(cfg) != nil\n\n\tenabledChannels := runningServices.ChannelManager.GetEnabledChannels()\n\tif len(enabledChannels) > 0 {\n\t\tfmt.Printf(\"✓ Channels enabled: %s\\n\", enabledChannels)\n\t} else {\n\t\tfmt.Println(\"⚠ Warning: No channels enabled\")","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/gateway/gateway.go#L446-L482","documentation":"channels.NewManager failed while constructing the channel manager, and the gateway aborted startup after stopping the media store cleanup goroutine. The error originates in m.initChannels(&cfg.Channels), which validates and instantiates each configured channel (unknown type, bad config, missing token).","triggerScenarios":"config.json declares a channel with an unsupported/misspelled type, a channel with missing required credentials, or duplicate channel names; NewManager returns the initChannels error and gateway.go wraps it as 'error creating channel manager' after stopping FileMediaStore.","commonSituations":"Upgrading the gateway to a version that renamed/removed a channel type; typos in the channels section; env vars for channel tokens unset at boot; malformed config.json after manual edit.","solutions":["Check the wrapped error from initChannels — it names the failing channel","Validate every entry under channels in config.json: correct type string and required fields/tokens","Ensure channel credential env vars are set in the gateway process environment","Run a config lint/dry-run if available before restart"],"exampleFix":"// before\n\"channels\": { \"telegramm\": { \"enabled\": true, \"token\": \"...\" } }\n// after\n\"channels\": { \"telegram\": { \"enabled\": true, \"token\": \"...\" } }","handlingStrategy":"validation","validationCode":"for name, ch := range cfg.Channels {\n    if !knownChannelTypes[ch.Type] {\n        return fmt.Errorf(\"unknown channel type %q for %s\", ch.Type, name)\n    }\n}","typeGuard":null,"tryCatchPattern":"cm, err := channels.NewManager(cfg, bus, store, opts...)\nif err != nil {\n    // manager constructor also stops media cleanup upstream; ensure fms.Stop() on your side\n    return fmt.Errorf(\"error creating channel manager: %w\", err)\n}","preventionTips":["Lint config.json channel types/tokens before restart","Use a config schema validator in CI","Start gateway with a minimal channels set and add channels incrementally"],"tags":["gateway","channels","config","startup","go"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}