chenhg5/cc-connect · critical

yuanbao: bot_token is required (format: app_key:app_secret)

Error message

yuanbao: bot_token is required (format: app_key:app_secret)

What it means

The yuanbao platform constructor requires a bot_token option in "app_key:app_secret" format; if the token is missing or splitting on ":" yields an empty app_key or app_secret, New returns this error. Configuration is rejected at startup rather than failing later at connection time.

Source

Thrown at platform/yuanbao/platform.go:70

	heartbeatTimer     *time.Timer
	dedupCleanupTimer  *time.Timer
	dedupSet           map[string]time.Time
	replyHBTimers      map[string]*time.Timer
	replyHBStop        map[string]chan struct{}
	reconnectAttempts  int
	shouldReconnect    bool
	done               chan struct{}
	pendingAcks        map[string]chan<- []byte
	pendingMu          sync.Mutex
	consecutiveHbFails int
}

func New(opts map[string]any) (core.Platform, error) {
	botToken, _ := opts["bot_token"].(string)
	appKey, appSecret := splitBotToken(botToken)
	allowFrom, _ := opts["allow_from"].(string)
	if appKey == "" || appSecret == "" {
		return nil, fmt.Errorf("yuanbao: bot_token is required (format: app_key:app_secret)")
	}
	apiDomain, _ := opts["api_domain"].(string)
	wsURL, _ := opts["ws_url"].(string)
	routeEnv, _ := opts["route_env"].(string)
	if apiDomain == "" {
		apiDomain = defaultAPIDomain
	}
	if wsURL == "" {
		wsURL = defaultWSURL
	}
	core.CheckAllowFrom("yuanbao", allowFrom)
	return &Platform{
		appKey: appKey, appSecret: appSecret, allowFrom: allowFrom,
		apiDomain: apiDomain, wsURL: wsURL, routeEnv: routeEnv,
		tokens:        newTokenManager(),
		dedupSet:      make(map[string]time.Time),
		replyHBTimers: make(map[string]*time.Timer),
		replyHBStop:   make(map[string]chan struct{}),

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Set bot_token in the yuanbao config block to "app_key:app_secret" with both parts non-empty
  2. Verify the credentials come from the yuanbao open-platform console and contain exactly one ":"
  3. Check config loading/env substitution isn't producing an empty value
  4. Remove stray quotes or whitespace around the token

Example fix

// before (config.toml)
[platform.yuanbao]
# bot_token = ""   # missing
// after
[platform.yuanbao]
bot_token = "your_app_key:your_app_secret"
Defensive patterns

Strategy: validation

Validate before calling

parts := strings.SplitN(cfg.BotToken, ":", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" { return errors.New("bot_token must be app_key:app_secret") }

Try / catch

pl, err := platform.New(opts); if err != nil && strings.Contains(err.Error(), "bot_token is required") { slog.Fatal("yuanbao misconfigured: set bot_token = \"app_key:app_secret\"") }

Prevention

When it happens

Trigger: Creating the platform with opts lacking "bot_token", an empty string, a token without the ":" separator, or an empty app_key/app_secret segment.

Common situations: Forgot to fill in bot_token in config.toml; pasted only the app_key without appending ":app_secret"; env var substitution produced an empty string; whitespace or quoting issues stripped the secret.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/ae352445cc64be09. Report an issue: GitHub.