fatedier/frp · error

getIncludeContents error: %v

Error message

getIncludeContents error: %v

What it means

After the [common] section validates, the legacy loader expands every glob in includes by reading and rendering those files (getIncludeContents). Any failure during that aggregation is wrapped as 'getIncludeContents error: %v'. The inner error is typically a render/parse failure of one of the included files, or a directory error from the earlier loop.

Source

Thrown at pkg/config/legacy/parse.go:52

	}
	configBuffer := bytes.NewBuffer(nil)
	configBuffer.Write(content)

	// Parse common section.
	cfg, err = UnmarshalClientConfFromIni(content)
	if err != nil {
		return
	}
	if err = cfg.Validate(); err != nil {
		err = fmt.Errorf("parse config error: %v", err)
		return
	}

	// Aggregate proxy configs from include files.
	var buf []byte
	buf, err = getIncludeContents(cfg.IncludeConfigFiles)
	if err != nil {
		err = fmt.Errorf("getIncludeContents error: %v", err)
		return
	}
	configBuffer.WriteString("\n")
	configBuffer.Write(buf)

	// Parse all proxy and visitor configs.
	proxyCfgs, visitorCfgs, err = LoadAllProxyConfsFromIni(cfg.User, configBuffer.Bytes(), cfg.Start)
	if err != nil {
		return
	}
	return
}

// getIncludeContents renders all configs from paths.
// files format can be a single file path or directory or regex path.
func getIncludeContents(paths []string) ([]byte, error) {
	out := bytes.NewBuffer(nil)
	for _, path := range paths {

View on GitHub (pinned to 6c8a8d0a97)

Solutions

  1. Check the wrapped error text to identify which operation failed
  2. Inspect every file matched by the includes glob: ls the expanded paths as the frpc user; validate template syntax ({{ .Envs.name }} references)
  3. Exclude stray files by narrowing the glob or moving non-config files out of the include directory

Example fix

# before
includes = /etc/frp/conf/*          # dir also holds .swp temp files

# after
includes = /etc/frp/conf/*.ini     # only real fragments match
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-render all include files before starting frpc
for _, f := range expandedIncludes {
    if _, err := config.GetRenderedConfFromFile(f); err != nil {
        return fmt.Errorf("include %s would fail to render: %w", f, err)
    }
}

Try / catch

if err := legacy.LoadConfigure(path); err != nil && strings.Contains(err.Error(), "getIncludeContents error") { /* unwrap cause, fix the named fragment, retry */ }

Prevention

When it happens

Trigger: A frpc.ini includes glob that matches files which cannot be read, or whose Go-template rendering (env var substitution via {{ .Envs.xxx }}) fails — e.g. referencing a template function that does not exist, or a file that disappeared between validation and read.

Common situations: Include directories containing a partially-written or corrupted file (editors' swap files matching the glob), template syntax errors in included INI fragments, or files with wrong permissions for the frpc user.

Related errors


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