fatedier/frp · warning
remote_port new key in section error: %v
Error message
remote_port new key in section error: %v
What it means
Sibling of error 158: after successfully writing local_port into a derived range section, the same NewKey call is made for remote_port. Failure wraps here. Like error 158, go-ini only errors on frozen sections or invalid characters in the value, so with ordinary numeric port values produced by fmt.Sprintf('%d', ...) this path is effectively unreachable.
Source
Thrown at pkg/config/legacy/client.go:331
}
// Templates
prefix := strings.TrimSpace(strings.TrimPrefix(section.Name(), "range:"))
for i := range localPorts {
tmpname := fmt.Sprintf("%s_%d", prefix, i)
tmpsection, err := f.NewSection(tmpname)
if err != nil {
return err
}
copySection(section, tmpsection)
if _, err := tmpsection.NewKey("local_port", fmt.Sprintf("%d", localPorts[i])); err != nil {
return fmt.Errorf("local_port new key in section error: %v", err)
}
if _, err := tmpsection.NewKey("remote_port", fmt.Sprintf("%d", remotePorts[i])); err != nil {
return fmt.Errorf("remote_port new key in section error: %v", err)
}
}
return nil
}
func copySection(source, target *ini.Section) {
for key, value := range source.KeysHash() {
_, _ = target.NewKey(key, value)
}
}
// GetDefaultClientConf returns a client configuration with default values.
// Note: Some default values here will be set to empty and will be converted to them
// new configuration through the 'Complete' function to set them as the default
// values of the new configuration.
func GetDefaultClientConf() ClientCommonConf {
return ClientCommonConf{View on GitHub (pinned to 6c8a8d0a97)
Solutions
- Keep remote_port values as clean numeric ranges/lists
- Avoid go-ini freeze options when feeding an ini.File to the legacy loader
- If it recurs, dump the offending [range:...] section and report upstream
Defensive patterns
Strategy: validation
Validate before calling
if !regexp.MustCompile(`^[0-9,\- ]+$`).MatchString(remotePortStr) {
return fmt.Errorf("remote_port contains invalid characters: %q", remotePortStr)
} Prevention
- Same hygiene as local_port: digits, commas, dashes only
- Validate both port strings before invoking the loader
- Report repeated occurrences upstream with the raw section
When it happens
Trigger: Same class as error 158: programmatically frozen ini.File, control characters in the derived section state, or section-name collisions from a malformed range prefix.
Common situations: Essentially none for file-based configs; only exotic programmatic use of the legacy loader.
Related errors
- local_port new key in section error: %v
- failed to render template for proxy %s: %v
- local_port or remote_port is empty
- local ports number should be same with remote ports number
- local_port and remote_port is necessary
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/d6a0000d01338ef7.
Report an issue: GitHub.