fish2018/pansou · error

站点地址不能为空

Error message

站点地址不能为空

What it means

normalizeBaseURL in the gying plugin rejects an empty site address. The user-provided base URL configuration, after trimming whitespace and trailing slashes, is an empty string, so no valid base URL can be constructed.

Solutions

  1. Set the site address in the gying plugin configuration to a real host, e.g. https://example.com.
  2. Strip quotes/whitespace when copying the URL into the config.
  3. Verify the config file is the one actually being loaded (right profile/env).

Example fix

// before (config)
{ "site": "" }
// after (config)
{ "site": "https://gying.example.org" }
Defensive patterns

Strategy: validation

Validate before calling

site := strings.TrimSpace(cfg.Site)
if site == "" {
    return errors.New("gying site address must be configured")
}

Try / catch

if err := plugin.Configure(cfg); err != nil {
    if strings.Contains(err.Error(), "站点地址不能为空") {
        return fmt.Errorf("config error: set the gying 'site' field: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: normalizeBaseURL: raw is empty or only whitespace (and optionally '/' characters), so baseURL == "" after TrimSpace/TrimRight.

Common situations: Plugin configured with an empty site field in the config file or UI; env/config value never set; whitespace-only value pasted by mistake.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at plugin/gying/gying.go:598

type GyingConfig struct {
	BaseURL   string    `json:"base_url"`
	UpdatedAt time.Time `json:"updated_at"`
}

func init() {
	p := &GyingPlugin{
		BaseAsyncPlugin: plugin.NewBaseAsyncPlugin("gying", 3),
	}

	plugin.RegisterGlobalPlugin(p)
}

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("站点地址不能包含参数或锚点")
	}

View on GitHub (pinned to beaa561337)