{"record":{"id":"2aeb054abe359f6b","repo":"fish2018/pansou","slug":"error-2aeb05","errorCode":null,"errorMessage":"站点地址不能为空","messagePattern":"站点地址不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":598,"sourceCode":"\ntype GyingConfig struct {\n\tBaseURL   string    `json:\"base_url\"`\n\tUpdatedAt time.Time `json:\"updated_at\"`\n}\n\nfunc init() {\n\tp := &GyingPlugin{\n\t\tBaseAsyncPlugin: plugin.NewBaseAsyncPlugin(\"gying\", 3),\n\t}\n\n\tplugin.RegisterGlobalPlugin(p)\n}\n\nfunc normalizeBaseURL(raw string) (string, error) {\n\tbaseURL := strings.TrimSpace(raw)\n\tbaseURL = strings.TrimRight(baseURL, \"/\")\n\tif baseURL == \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址不能为空\")\n\t}\n\tif !strings.HasPrefix(baseURL, \"http://\") && !strings.HasPrefix(baseURL, \"https://\") {\n\t\tbaseURL = \"https://\" + baseURL\n\t}\n\n\tparsed, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"站点地址格式错误: %v\", err)\n\t}\n\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址必须以 http:// 或 https:// 开头\")\n\t}\n\tif parsed.Host == \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址缺少域名\")\n\t}\n\tif parsed.RawQuery != \"\" || parsed.Fragment != \"\" {\n\t\treturn \"\", fmt.Errorf(\"站点地址不能包含参数或锚点\")\n\t}","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L580-L616","documentation":"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.","triggerScenarios":"normalizeBaseURL: raw is empty or only whitespace (and optionally '/' characters), so baseURL == \"\" after TrimSpace/TrimRight.","commonSituations":"Plugin configured with an empty site field in the config file or UI; env/config value never set; whitespace-only value pasted by mistake.","solutions":["Set the site address in the gying plugin configuration to a real host, e.g. https://example.com.","Strip quotes/whitespace when copying the URL into the config.","Verify the config file is the one actually being loaded (right profile/env)."],"exampleFix":"// before (config)\n{ \"site\": \"\" }\n// after (config)\n{ \"site\": \"https://gying.example.org\" }","handlingStrategy":"validation","validationCode":"site := strings.TrimSpace(cfg.Site)\nif site == \"\" {\n    return errors.New(\"gying site address must be configured\")\n}","typeGuard":null,"tryCatchPattern":"if err := plugin.Configure(cfg); err != nil {\n    if strings.Contains(err.Error(), \"站点地址不能为空\") {\n        return fmt.Errorf(\"config error: set the gying 'site' field: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate config at startup and fail fast with a clear message","Provide a default/example value in the config template","Trim whitespace when reading user-supplied config values","Add a UI/config check that the site field is non-empty before saving"],"tags":["configuration","url","validation","go"],"backgroundTag":"empty-required-field","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}