{"record":{"id":"89b9178602e562d3","repo":"fatedier/frp","slug":"failed-to-set-config-source-w","errorCode":null,"errorMessage":"failed to set config source: %w","messagePattern":"failed to set config source: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/frpc/sub/proxy.go","lineNumber":147,"sourceCode":"\t\t\terr := startService(clientCfg, nil, []v1.VisitorConfigurer{visitorCfg}, unsafeFeatures, \"\")\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t},\n\t}\n}\n\nfunc startService(\n\tcfg *v1.ClientCommonConfig,\n\tproxyCfgs []v1.ProxyConfigurer,\n\tvisitorCfgs []v1.VisitorConfigurer,\n\tunsafeFeatures *security.UnsafeFeatures,\n\tcfgFile string,\n) error {\n\tconfigSource := source.NewConfigSource()\n\tif err := configSource.ReplaceAll(proxyCfgs, visitorCfgs); err != nil {\n\t\treturn fmt.Errorf(\"failed to set config source: %w\", err)\n\t}\n\taggregator := source.NewAggregator(configSource)\n\treturn startServiceWithAggregator(cfg, aggregator, unsafeFeatures, cfgFile)\n}\n","sourceCodeStart":129,"sourceCodeEnd":152,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/cmd/frpc/sub/proxy.go#L129-L152","documentation":"While starting an inline frpc service with explicitly provided proxy/visitor configurers, source.NewConfigSource().ReplaceAll(proxyCfgs, visitorCfgs) failed. ReplaceAll validates and normalizes every configurer before storing it, so one of the supplied proxy or visitor configs is invalid at the source layer.","triggerScenarios":"Calling startService with a slice containing a configurer whose type or name is unsupported, empty, duplicated, or whose concrete type the source layer cannot handle.","commonSituations":"Embedding frpc and passing programmatically built v1.ProxyConfigurer objects with missing required fields; duplicate proxy names across the supplied slices; a nil or wrong-typed configurer slipping into the slice during refactoring.","solutions":["Log the wrapped inner error; it names the exact offending configurer, so fix that entry's name/type fields.","Validate each configurer before calling startService (see defense snippet) so bad entries fail with better context.","Deduplicate proxy/visitor names before assembly."],"exampleFix":"// before\nerr := svc.Start()\n\n// after: pre-validate to surface the bad configurer with its name\nfor _, p := range proxyCfgs {\n    base := p.GetBaseConfig()\n    if base == nil || base.Name == \"\" {\n        return fmt.Errorf(\"proxy configurer with empty name\")\n    }\n}","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, p := range proxyCfgs {\n    b := p.GetBaseConfig()\n    if b == nil || b.Name == \"\" || seen[b.Name] {\n        return fmt.Errorf(\"invalid or duplicate proxy configurer\")\n    }\n    seen[b.Name] = true\n}","typeGuard":null,"tryCatchPattern":"if err := configSource.ReplaceAll(proxyCfgs, visitorCfgs); err != nil {\n    return fmt.Errorf(\"config rejected: %w\", err) // inner error names the entry\n}","preventionTips":["Validate programmatically built configurers before startService","Uniqueness-check names at construction time","Log the wrapped inner error verbatim for diagnosis"],"tags":["config","embedding","frpc","validation"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}