sipeed/picoclaw · error

pico token is required

Error message

pico token is required

What it means

Validation guard inside NewPicoChannel: the channel constructor refuses to build a Pico Protocol channel when the configured token is empty. The token authenticates the bot against the pico server, so construction aborts before any connection state is created.

Solutions

  1. Set a non-empty token in the pico channel settings before creating the channel
  2. Check that config decoding (bc.Decode) actually populated the token field and the YAML key is spelled correctly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/channels/pico/pico.go:119 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/67dc075297ac2826. Report an issue: GitHub.

Appendix: source

Thrown at pkg/channels/pico/pico.go:119

	connections        map[string]*picoConn            // connID -> *picoConn
	sessionConnections map[string]map[string]*picoConn // sessionID -> connID -> *picoConn
	connsMu            sync.RWMutex
	ctx                context.Context
	cancel             context.CancelFunc
	progress           *channels.ToolFeedbackAnimator
	deleteMessageFn    func(context.Context, string, string) error
	// broadcastFn lets tests intercept outbound broadcasts. nil → broadcastToSession.
	broadcastFn func(chatID string, msg PicoMessage) error
}

// NewPicoChannel creates a new Pico Protocol channel.
func NewPicoChannel(
	bc *config.Channel,
	cfg *config.PicoSettings,
	messageBus *bus.MessageBus,
) (*PicoChannel, error) {
	if cfg.Token.String() == "" {
		return nil, fmt.Errorf("pico token is required")
	}

	base := channels.NewBaseChannel("pico", cfg, messageBus, bc.AllowFrom)

	allowOrigins := cfg.AllowOrigins
	checkOrigin := func(r *http.Request) bool {
		if len(allowOrigins) == 0 {
			return true // allow all if not configured
		}
		origin := r.Header.Get("Origin")
		for _, allowed := range allowOrigins {
			if allowed == "*" || allowed == origin {
				return true
			}
		}
		return false
	}

View on GitHub (pinned to 49183d7e8d)