chenhg5/cc-connect · error
%s: invalid domain %q: %w
Error message
%s: invalid domain %q: %w
What it means
The optional domain option, when set, must parse as a valid request URI via url.ParseRequestURI; otherwise newPlatform aborts. This catches malformed Feishu/Lark API base URLs before any client is built.
Source
Thrown at platform/feishu/feishu.go:341
func (p *Platform) SetCardNavigationHandler(h core.CardNavigationHandler) {
p.cardNavHandler = h
}
func New(opts map[string]any) (core.Platform, error) {
return newPlatform("feishu", lark.FeishuBaseUrl, opts)
}
func newPlatform(name, domain string, opts map[string]any) (core.Platform, error) {
appID, _ := opts["app_id"].(string)
appSecret, _ := opts["app_secret"].(string)
if appID == "" || appSecret == "" {
return nil, fmt.Errorf("%s: app_id and app_secret are required", name)
}
if v, ok := opts["domain"].(string); ok {
v = strings.TrimSpace(v)
if v != "" {
if _, err := url.ParseRequestURI(v); err != nil {
return nil, fmt.Errorf("%s: invalid domain %q: %w", name, v, err)
}
domain = v
}
}
reactionEmoji, _ := opts["reaction_emoji"].(string)
if reactionEmoji == "" {
reactionEmoji = "OnIt"
}
if v, ok := opts["reaction_emoji"].(string); ok && v == "none" {
reactionEmoji = ""
}
doneEmoji, _ := opts["done_emoji"].(string)
if doneEmoji == "none" {
doneEmoji = ""
}
allowFrom, _ := opts["allow_from"].(string)
core.CheckAllowFrom(name, allowFrom)
allowChat, _ := opts["allow_chat"].(string)View on GitHub (pinned to 4000b2338a)
Solutions
- Include the scheme: domain = "https://open.feishu.cn".
- Remove whitespace or invisible characters from the domain value.
- Omit the domain option entirely to use the default Feishu domain.
Example fix
// before (config.toml) domain = "open.feishu.cn" // after domain = "https://open.feishu.cn"
Defensive patterns
Strategy: validation
Validate before calling
d := strings.TrimSpace(cfg.Domain)
if d != "" {
if _, err := url.ParseRequestURI(d); err != nil {
log.Fatalf("invalid feishu domain %q: %v", d, err)
}
} Prevention
- Always include the https:// scheme in domain values.
- Omit domain entirely unless using Lark or a custom gateway.
- Test the URL with curl before putting it in config.
When it happens
Trigger: domain = "open.feishu.cn" (missing scheme), "https://open feishu.cn" (space), or any string ParseRequestURI rejects — e.g. missing protocol or control characters.
Common situations: Users omitting https:// from the domain; pasting URLs with trailing whitespace/newlines (trim handles plain spaces, not embedded ones); using the Lark domain url.open... misspellings.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- expected number, got %T
- %s: app_id and app_secret are required
- %s: invalid progress_style %q (want legacy, compact, or card
- %s: invalid image_batch_window_ms %v: %w
- %s: image_batch_window_ms must be >= 0, got %d
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/90ae892c15998825.
Report an issue: GitHub.