chenhg5/cc-connect · error

qqbot: app_id is required

Error message

qqbot: app_id is required

What it means

The qqbot platform constructor New() requires an "app_id" string in its options map and fails fast at startup if it is missing or empty. This is configuration validation before any network activity, so a bad config is caught immediately when the platform is created.

Source

Thrown at platform/qqbot/qqbot.go:152

	ReferencedMessage *quotedMessage `json:"referenced_message,omitempty"`
	SourceMessage     *quotedMessage `json:"source_message,omitempty"`
}

// msgTypeQuote indicates a quote (reply) message in the QQ Bot API.
const msgTypeQuote = 103

// msgElement represents a message element in QQ Bot event.
// For quote messages (message_type=103), msg_elements[0] contains the quoted content.
type msgElement struct {
	Content     string       `json:"content"`
	Attachments []attachment `json:"attachments"`
}

// New creates a new QQ Bot platform from config options.
func New(opts map[string]any) (core.Platform, error) {
	appID, _ := opts["app_id"].(string)
	if appID == "" {
		return nil, fmt.Errorf("qqbot: app_id is required")
	}
	appSecret, _ := opts["app_secret"].(string)
	if appSecret == "" {
		return nil, fmt.Errorf("qqbot: app_secret is required")
	}

	sandbox, _ := opts["sandbox"].(bool)
	allowFrom, _ := opts["allow_from"].(string)
	shareSessionInChannel, _ := opts["share_session_in_channel"].(bool)
	markdownSupport, _ := opts["markdown_support"].(bool)

	intents := defaultIntents
	if v, ok := opts["intents"].(int); ok && v > 0 {
		intents = v
	} else if v, ok := opts["intents"].(float64); ok && v > 0 {
		intents = int(v)
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Add app_id = "<your QQ bot app id>" to the qqbot platform section of config.toml (get it from the QQ Open Platform bot settings).
  2. Verify the key is inside the correct TOML table ([platforms.qqbot]) and spelled app_id, not appId or appid.
  3. Ensure the value is a quoted string, not a number — a bare integer fails the string type assertion.
  4. Confirm the environment that generates your config (templates, envsubst) actually emits the app_id field.

Example fix

// before
p, err := qqbot.New(map[string]any{"app_secret": "s3cret"}) // missing app_id
// after
p, err := qqbot.New(map[string]any{"app_id": "123456", "app_secret": "s3cret"})
Defensive patterns

Strategy: validation

Validate before calling

appID, _ := opts["app_id"].(string)
if appID == "" {
	return errors.New("qqbot: app_id must be a non-empty string before calling New")
}

Type guard

func validOpts(opts map[string]any) bool {
	id, ok := opts["app_id"].(string)
	return ok && id != ""
}

Try / catch

p, err := qqbot.New(opts)
if err != nil {
	return fmt.Errorf("loading qqbot platform: %w", err) // fails fast at startup
}

Prevention

When it happens

Trigger: Calling qqbot.New(opts) (directly or via config loading at cc-connect startup) when opts has no "app_id" key, has app_id set to "", or app_id is of a non-string type (the type assertion yields "" for non-strings).

Common situations: TOML config missing the app_id field under [platforms.qqbot] (or placed under the wrong section). App ID quoted incorrectly or left empty. Loading config from an env-based renderer that dropped the key. Running tests that intentionally omit credentials.

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/0b5428665514bcaf. Report an issue: GitHub.