{"record":{"id":"0b5428665514bcaf","repo":"chenhg5/cc-connect","slug":"qqbot-app-id-is-required","errorCode":null,"errorMessage":"qqbot: app_id is required","messagePattern":"qqbot: app_id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qqbot/qqbot.go","lineNumber":152,"sourceCode":"\tReferencedMessage *quotedMessage `json:\"referenced_message,omitempty\"`\n\tSourceMessage     *quotedMessage `json:\"source_message,omitempty\"`\n}\n\n// msgTypeQuote indicates a quote (reply) message in the QQ Bot API.\nconst msgTypeQuote = 103\n\n// msgElement represents a message element in QQ Bot event.\n// For quote messages (message_type=103), msg_elements[0] contains the quoted content.\ntype msgElement struct {\n\tContent     string       `json:\"content\"`\n\tAttachments []attachment `json:\"attachments\"`\n}\n\n// New creates a new QQ Bot platform from config options.\nfunc New(opts map[string]any) (core.Platform, error) {\n\tappID, _ := opts[\"app_id\"].(string)\n\tif appID == \"\" {\n\t\treturn nil, fmt.Errorf(\"qqbot: app_id is required\")\n\t}\n\tappSecret, _ := opts[\"app_secret\"].(string)\n\tif appSecret == \"\" {\n\t\treturn nil, fmt.Errorf(\"qqbot: app_secret is required\")\n\t}\n\n\tsandbox, _ := opts[\"sandbox\"].(bool)\n\tallowFrom, _ := opts[\"allow_from\"].(string)\n\tshareSessionInChannel, _ := opts[\"share_session_in_channel\"].(bool)\n\tmarkdownSupport, _ := opts[\"markdown_support\"].(bool)\n\n\tintents := defaultIntents\n\tif v, ok := opts[\"intents\"].(int); ok && v > 0 {\n\t\tintents = v\n\t} else if v, ok := opts[\"intents\"].(float64); ok && v > 0 {\n\t\tintents = int(v)\n\t}\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qqbot/qqbot.go#L134-L170","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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).","Verify the key is inside the correct TOML table ([platforms.qqbot]) and spelled app_id, not appId or appid.","Ensure the value is a quoted string, not a number — a bare integer fails the string type assertion.","Confirm the environment that generates your config (templates, envsubst) actually emits the app_id field."],"exampleFix":"// before\np, err := qqbot.New(map[string]any{\"app_secret\": \"s3cret\"}) // missing app_id\n// after\np, err := qqbot.New(map[string]any{\"app_id\": \"123456\", \"app_secret\": \"s3cret\"})","handlingStrategy":"validation","validationCode":"appID, _ := opts[\"app_id\"].(string)\nif appID == \"\" {\n\treturn errors.New(\"qqbot: app_id must be a non-empty string before calling New\")\n}","typeGuard":"func validOpts(opts map[string]any) bool {\n\tid, ok := opts[\"app_id\"].(string)\n\treturn ok && id != \"\"\n}","tryCatchPattern":"p, err := qqbot.New(opts)\nif err != nil {\n\treturn fmt.Errorf(\"loading qqbot platform: %w\", err) // fails fast at startup\n}","preventionTips":["Keep app_id and app_secret together in the [platforms.qqbot] TOML table.","Quote the app id as a string even if it is numeric.","Run cc-connect with a config linter / doctor check before deploying.","If generating config from env vars, assert required keys are non-empty at render time."],"tags":["config","qqbot","startup"],"backgroundTag":"missing-required-config-field","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}