sipeed/picoclaw · error

dingtalk client_id and client_secret are required

Error message

dingtalk client_id and client_secret are required

What it means

NewDingTalkChannel fails fast when either ClientID or ClientSecret in DingTalkSettings is empty. It is a construction-time config validation fired before any SDK client is built, so the channel is never registered when credentials are missing.

Source

Thrown at pkg/channels/dingtalk/dingtalk.go:45

	*channels.BaseChannel
	config       *config.DingTalkSettings
	clientID     string
	clientSecret string
	streamClient *client.StreamClient
	ctx          context.Context
	cancel       context.CancelFunc
	// Map to store session webhooks for each chat
	sessionWebhooks sync.Map // chatID -> sessionWebhook
}

// NewDingTalkChannel creates a new DingTalk channel instance
func NewDingTalkChannel(
	bc *config.Channel,
	cfg *config.DingTalkSettings,
	messageBus *bus.MessageBus,
) (*DingTalkChannel, error) {
	if cfg.ClientID == "" || cfg.ClientSecret.String() == "" {
		return nil, fmt.Errorf("dingtalk client_id and client_secret are required")
	}

	// Set the logger for the Stream SDK
	dinglog.SetLogger(logger.NewLogger("dingtalk"))

	base := channels.NewBaseChannel("dingtalk", cfg, messageBus, bc.AllowFrom,
		channels.WithMaxMessageLength(20000),
		channels.WithGroupTrigger(bc.GroupTrigger),
		channels.WithReasoningChannelID(bc.ReasoningChannelID),
	)

	return &DingTalkChannel{
		BaseChannel:  base,
		config:       cfg,
		clientID:     cfg.ClientID,
		clientSecret: cfg.ClientSecret.String(),
	}, nil
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Set both dingtalk.client_id and dingtalk.client_secret in the config (create a robot on DingTalk Open Platform and copy its AppKey/AppSecret)
  2. If the secret comes from an environment variable, verify it is set in the service environment (docker env, systemd EnvironmentFile) and restart
  3. Check YAML indentation and exact key names against the config reference

Example fix

# before
channels:
  dingtalk:
    enabled: true

# after
channels:
  dingtalk:
    enabled: true
    client_id: "ding0nxxxxxxx"
    client_secret: "your-app-secret"
Defensive patterns

Strategy: validation

Validate before calling

func validateDingTalkConfig(cfg *config.DingTalkSettings) error {
    if cfg.ClientID == "" || cfg.ClientSecret.String() == "" {
        return fmt.Errorf("dingtalk client_id and client_secret are required")
    }
    return nil
}

Prevention

When it happens

Trigger: Constructing the dingtalk channel with a config block that omits client_id/client_secret, has empty strings, or references an env var for the secret that is unset at process start.

Common situations: First-time setup using a config template without filling values, typoed YAML keys, secret sourced from an env var missing in docker-compose/systemd units, deploying with a different environment than local dev.

Related errors


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