chenhg5/cc-connect · error

webex: token is required

Error message

webex: token is required

What it means

New constructs the Webex platform from config options. A missing or whitespace-only 'token' option makes construction fail immediately with this error, since no API call is possible without a bot token.

Source

Thrown at platform/webex/webex.go:51

	allowFrom []string // lowercased email allowlist; empty = allow all

	client webexClient

	mu               sync.RWMutex
	handler          core.MessageHandler
	lifecycleHandler core.PlatformLifecycleHandler
	cancel           context.CancelFunc
	stopping         bool
	selfID           string // bot's own personId
	selfEmail        string // bot's own email (Mercury actor uses email)
	deviceURL        string // for cleanup on Stop()
}

// New constructs a Webex platform from config options.
func New(opts map[string]any) (core.Platform, error) {
	token, _ := opts["token"].(string)
	if strings.TrimSpace(token) == "" {
		return nil, fmt.Errorf("webex: token is required")
	}
	rawAllow, _ := opts["allow_from"].(string)
	core.CheckAllowFrom("webex", rawAllow)

	return &Platform{
		token:     token,
		allowFrom: parseAllowFrom(rawAllow),
		client:    newHTTPClient(token),
	}, nil
}

func (p *Platform) Name() string { return "webex" }

// self returns the bot's own personId under lock.
func (p *Platform) self() string {
	p.mu.RLock()
	defer p.mu.RUnlock()
	return p.selfID

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Add token = "<bot-access-token>" to the webex platform config section
  2. Set the token from the environment if the config templating supports it, and verify it is exported
  3. Trim whitespace / re-copy the token from the Webex developer portal
  4. Check that the config file being loaded is the one you edited

Example fix

// before
opts := map[string]any{"allow_from": ""}
p, _ := webex.New(opts)
// after
opts := map[string]any{"token": os.Getenv("WEBEX_TOKEN"), "allow_from": ""}
p, err := webex.New(opts) // err != nil handled
Defensive patterns

Strategy: validation

Validate before calling

tok, _ := opts["token"].(string)
if strings.TrimSpace(tok) == "" { return errors.New("webex token must be set in config") }

Try / catch

p, err := webex.New(opts)
if err != nil { return fmt.Errorf("init webex platform: %w", err) }

Prevention

When it happens

Trigger: Calling New (or starting the platform via config) with opts lacking the 'token' key, token set to "", or token containing only spaces/tabs.

Common situations: config.toml [platform.webex] section missing the token field; environment variable for the token not exported; token placeholder never replaced; YAML/TOML quoting issues producing empty string.

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/6db4d83b5e2161f7. Report an issue: GitHub.