chenhg5/cc-connect · error
line: channel_secret and channel_token are required
Error message
line: channel_secret and channel_token are required
What it means
line.New validates that the options map contains non-empty channel_secret and channel_token values and fails fast with this error otherwise. The LINE Messaging API requires both to sign/verify webhooks and to authenticate API calls. New returns nil platform and this error when either credential is missing or empty.
Source
Thrown at platform/line/line.go:49
type Platform struct {
channelSecret string
channelToken string
allowFrom string
port string
callbackPath string
bot *messaging_api.MessagingApiAPI
server *http.Server
handler core.MessageHandler
userNameCache sync.Map // userID -> display name
groupNameCache sync.Map // groupID -> group name
}
func New(opts map[string]any) (core.Platform, error) {
secret, _ := opts["channel_secret"].(string)
token, _ := opts["channel_token"].(string)
allowFrom, _ := opts["allow_from"].(string)
if secret == "" || token == "" {
return nil, fmt.Errorf("line: channel_secret and channel_token are required")
}
port, _ := opts["port"].(string)
if port == "" {
port = "8080"
}
path, _ := opts["callback_path"].(string)
if path == "" {
path = "/callback"
}
core.CheckAllowFrom("line", allowFrom)
return &Platform{
channelSecret: secret,
channelToken: token,
allowFrom: allowFrom,
port: port,
callbackPath: path,View on GitHub (pinned to 4000b2338a)
Solutions
- Add valid channel_secret and channel_token string values from the LINE Developers Console to the options.
- Verify the option keys are exactly "channel_secret" and "channel_token".
- Check config.toml interpolation: ensure env vars like ${LINE_CHANNEL_TOKEN} are actually set in the shell/service environment.
- Ensure the values are strings, not numbers or other types.
Example fix
// before
line.New(map[string]any{"channel_token": token})
// after
line.New(map[string]any{"channel_secret": secret, "channel_token": token}) Defensive patterns
Strategy: validation
Validate before calling
// Go: validate options before calling line.New
func validLineOpts(opts map[string]any) error {
secret, _ := opts["channel_secret"].(string)
token, _ := opts["channel_token"].(string)
if secret == "" || token == "" {
return fmt.Errorf("line: channel_secret and channel_token must be non-empty strings (got secret=%q, token=%q)", secret, token)
}
return nil
} Type guard
// Go: narrowing check
secret, secretOK := opts["channel_secret"].(string)
token, tokenOK := opts["channel_token"].(string)
if !secretOK || !tokenOK || secret == "" || token == "" {
return errors.New("line: channel_secret and channel_token must be non-empty strings")
} Prevention
- Keep credentials in a config template and validate at startup before registering platforms.
- Use consistent snake_case key names matching the platform adapter's expectations.
- Fail fast with a startup config check rather than letting empty env substitutions through.
- Store tokens in a secret manager instead of hand-edited config to avoid copy errors.
When it happens
Trigger: Calling line.New(opts) with opts missing the channel_secret or channel_token keys, or with either value set to "" (empty string), or with values of a non-string type (type assertion yields "").
Common situations: config.toml [platforms.line] section missing the fields; environment variable substitution resolving to empty; typo'd key names (channelToken instead of channel_token); passing ints or other non-string types.
Related errors
- tmux: 'session' option is required (name of the tmux session
- config: relay.visibility must be "full", "summary", or "none
- config: at least one [[projects]] entry is required
- config: %s.name is required
- config: %s.agent.type is required
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/8a296381a6cb0f35.
Report an issue: GitHub.