fatedier/frp · error

failed to set config source: %w

Error message

failed to set config source: %w

What it means

runClientWithAggregator failed at the same ReplaceAll step as error 131, but for configs loaded from files (ClientConfigLoadResult): the proxies and visitors parsed from config files could not be registered into the config source. The wrapped error identifies the first invalid entry.

Source

Thrown at cmd/frpc/sub/root.go:140

func runClient(cfgFilePath string, unsafeFeatures *security.UnsafeFeatures) error {
	// Load configuration
	result, err := config.LoadClientConfigResult(cfgFilePath, strictConfigMode)
	if err != nil {
		return err
	}
	if result.IsLegacyFormat {
		fmt.Printf("WARNING: ini format is deprecated and the support will be removed in the future, " +
			"please use yaml/json/toml format instead!\n")
	}

	return runClientWithAggregator(result, unsafeFeatures, cfgFilePath)
}

// runClientWithAggregator runs the client using the internal source aggregator.
func runClientWithAggregator(result *config.ClientConfigLoadResult, unsafeFeatures *security.UnsafeFeatures, cfgFilePath string) error {
	configSource := source.NewConfigSource()
	if err := configSource.ReplaceAll(result.Proxies, result.Visitors); err != nil {
		return fmt.Errorf("failed to set config source: %w", err)
	}

	var storeSource *source.StoreSource

	if result.Common.Store.IsEnabled() {
		storePath := result.Common.Store.Path
		if storePath != "" && cfgFilePath != "" && !filepath.IsAbs(storePath) {
			storePath = filepath.Join(filepath.Dir(cfgFilePath), storePath)
		}

		s, err := source.NewStoreSource(source.StoreSourceConfig{
			Path: storePath,
		})
		if err != nil {
			return fmt.Errorf("failed to create store source: %w", err)
		}
		storeSource = s
	}

View on GitHub (pinned to 6c8a8d0a97)

Solutions

  1. Read the inner error message; it names the proxy/visitor that failed, so grep the config files for that name.
  2. Check for duplicate name fields across all included config files.
  3. Validate the file with the same rules before startup (see defense snippet).
  4. Fix or remove the offending section and reload.

Example fix

# before (frpc.toml)
[[proxies]]
name = "web"
type = "tcp"
[[proxies]]
name = "web"
type = "http"

# after
[[proxies]]
name = "web"
type = "tcp"
[[proxies]]
name = "web2"
type = "http"
Defensive patterns

Strategy: validation

Validate before calling

// Lint the loaded result before starting the service
names := map[string]bool{}
for _, p := range result.Proxies {
    b := p.GetBaseConfig()
    if names[b.Name] {
        return fmt.Errorf("duplicate proxy name %q", b.Name)
    }
    names[b.Name] = true
}

Prevention

When it happens

Trigger: A config file whose [[proxies]]/[[visitors]] section has an invalid or duplicate name, an unsupported type string, or fields that survive file parsing but fail source-layer validation.

Common situations: Two proxies with the same name in one file or across included files; typo in the proxy type (e.g., 'tcpx'); migration leftovers where legacy keys map to incomplete v1 objects.

Related errors


AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15). Data as JSON: /api/errors/bde008e0af189eaf. Report an issue: GitHub.