fish2018/pansou · error

站点地址缺少域名

Error message

站点地址缺少域名

What it means

Validation error in normalizeBaseURL (plugin/gying/gying.go:612): the configured site address parsed successfully but has an empty Host component (e.g. only a scheme was given), so no requests could be addressed. Indicates a misconfigured base URL lacking a domain.

Solutions

  1. Supply the full address including the domain: https://your-gying-site.org.
  2. Check that environment/config templating actually substituted the host placeholder.
  3. Re-copy the URL from the browser address bar and verify nothing was truncated.

Example fix

// before
"site": "https://"
// after
"site": "https://gying.example.org"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(strings.TrimSpace(cfg.Site))
if err != nil || u.Host == "" {
    return fmt.Errorf("gying site address must include a host, e.g. https://example.org")
}

Try / catch

if err := plugin.Configure(cfg); err != nil {
    if strings.Contains(err.Error(), "站点地址缺少域名") {
        return fmt.Errorf("gying site config is missing the domain: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: normalizeBaseURL: parsed.Scheme is http/https but parsed.Host == "" — e.g. input 'https://' or 'https:///path' where the authority part is missing.

Common situations: 配置中只填了路径或前缀;域名部分被误删。

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


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/f019c2273afc98e7. Report an issue: GitHub.

Appendix: source

Thrown at plugin/gying/gying.go:612

func normalizeBaseURL(raw string) (string, error) {
	baseURL := strings.TrimSpace(raw)
	baseURL = strings.TrimRight(baseURL, "/")
	if baseURL == "" {
		return "", fmt.Errorf("站点地址不能为空")
	}
	if !strings.HasPrefix(baseURL, "http://") && !strings.HasPrefix(baseURL, "https://") {
		baseURL = "https://" + baseURL
	}

	parsed, err := url.Parse(baseURL)
	if err != nil {
		return "", fmt.Errorf("站点地址格式错误: %v", err)
	}
	if parsed.Scheme != "http" && parsed.Scheme != "https" {
		return "", fmt.Errorf("站点地址必须以 http:// 或 https:// 开头")
	}
	if parsed.Host == "" {
		return "", fmt.Errorf("站点地址缺少域名")
	}
	if parsed.RawQuery != "" || parsed.Fragment != "" {
		return "", fmt.Errorf("站点地址不能包含参数或锚点")
	}
	if parsed.Path != "" && parsed.Path != "/" {
		return "", fmt.Errorf("站点地址不能包含路径")
	}

	// HTTP clients do not consistently convert Unicode hostnames to IDNA.
	// Store the ASCII form so both the config page and requests are reliable.
	hostname, err := idna.Lookup.ToASCII(parsed.Hostname())
	if err != nil {
		return "", fmt.Errorf("站点域名格式错误: %v", err)
	}
	host := hostname
	if port := parsed.Port(); port != "" {
		host += ":" + port
	}

View on GitHub (pinned to beaa561337)