chenhg5/cc-connect · error

tuitui: invalid group_policy %q (want allowlist, open, or di

Error message

tuitui: invalid group_policy %q (want allowlist, open, or disabled)

What it means

The optional group_policy option only accepts "allowlist", "open", or "disabled" (case-insensitive); any other value makes New() fail. This policy controls how the bot treats group chats, so an unknown value is treated as a config error rather than silently defaulting.

Source

Thrown at platform/tuitui/tuitui.go:131

		apiBase = defaultAPIBase
	}
	wsBase, _ := opts["ws_base"].(string)
	if wsBase == "" {
		wsBase = defaultWSBase
	}
	allowFrom, _ := opts["allow_from"].(string)
	core.CheckAllowFrom("tuitui", allowFrom)
	groupAllowFrom, _ := opts["group_allow_from"].(string)
	ignoreFrom, _ := opts["ignore_from"].(string)
	groupPolicy, _ := opts["group_policy"].(string)
	if groupPolicy == "" {
		groupPolicy = "allowlist"
	}
	groupPolicy = strings.ToLower(strings.TrimSpace(groupPolicy))
	switch groupPolicy {
	case "allowlist", "open", "disabled":
	default:
		return nil, fmt.Errorf("tuitui: invalid group_policy %q (want allowlist, open, or disabled)", groupPolicy)
	}
	requireMention := true
	if v, ok := opts["require_mention"].(bool); ok {
		requireMention = v
	}
	receiveReaction := "收到"
	if v, ok := opts["receive_reaction"].(string); ok {
		receiveReaction = strings.TrimSpace(v)
	}
	shareSessionInChannel, _ := opts["share_session_in_channel"].(bool)
	pendingHistoryLimit := defaultHistoryLimit
	if v, ok := intOption(opts["history_limit"]); ok {
		if v < 0 {
			return nil, fmt.Errorf("tuitui: history_limit must be non-negative")
		}
		pendingHistoryLimit = v
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Change group_policy to exactly one of: allowlist, open, or disabled.
  2. Remember matching is lowercase after trim — "Allowlist" works but "allow list" does not.
  3. Remove the group_policy key entirely to use the default (allowlist).
  4. Check config.example.toml for documented accepted values.

Example fix

// before
group_policy = "whitelist"
// after
group_policy = "allowlist"
Defensive patterns

Strategy: validation

Validate before calling

var validPolicies = map[string]bool{"allowlist": true, "open": true, "disabled": true}
policy := strings.ToLower(strings.TrimSpace(cfg["group_policy"]))
if policy != "" && !validPolicies[policy] {
    return fmt.Errorf("group_policy must be allowlist|open|disabled, got %q", policy)
}

Type guard

func isValidGroupPolicy(v string) bool {
    switch strings.ToLower(strings.TrimSpace(v)) {
    case "", "allowlist", "open", "disabled": return true
    }
    return false
}

Try / catch

plat, err := tuitui.New(opts)
if err != nil {
    var cfgErr *InvalidConfigError
    if errors.As(err, &cfgErr) {
        return fmt.Errorf("fix config.toml: %v", cfgErr)
    }
    return err
}

Prevention

When it happens

Trigger: Setting group_policy = "Allow List", "whitelist", "block", or any string not in the three-value set (after lowercase+trim) in the tuitui platform config.

Common situations: Copying policy vocabulary from another platform's config; typo like "allow-list" or "disable"; expecting a boolean-like true/false value; localization of the config file introducing translated words.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/73fc4adc5067777d. Report an issue: GitHub.