fatedier/frp · warning
proxy name cannot be empty
Error message
proxy name cannot be empty
What it means
validateProxyName rejected a proxy passed to AddProxy or UpdateProxy because its base config Name is empty (a nil proxy is a separate error). Every proxy must be named before entering the store, since the name is the map key and the persistence identity.
Source
Thrown at pkg/config/source/validation.go:29
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package source
import (
"fmt"
v1 "github.com/fatedier/frp/pkg/config/v1"
)
func validateProxyName(proxy v1.ProxyConfigurer) (string, error) {
if proxy == nil {
return "", fmt.Errorf("proxy cannot be nil")
}
name := proxy.GetBaseConfig().Name
if name == "" {
return "", fmt.Errorf("proxy name cannot be empty")
}
return name, nil
}
func validateVisitorName(visitor v1.VisitorConfigurer) (string, error) {
if visitor == nil {
return "", fmt.Errorf("visitor cannot be nil")
}
name := visitor.GetBaseConfig().Name
if name == "" {
return "", fmt.Errorf("visitor name cannot be empty")
}
return name, nil
}
View on GitHub (pinned to 6c8a8d0a97)
Solutions
- Set a unique non-empty name on the base config before calling Add/Update
- If the name comes from user input, validate it server-side before constructing the configurer
- Log the offending entry when validation fails so the source of the empty name is findable
Example fix
// before
cfg := &v1.TCPProxyConfig{LocalPort: 22}
err := store.AddProxy(cfg) // proxy name cannot be empty
// after
cfg := &v1.TCPProxyConfig{ProxyBaseConfig: v1.ProxyBaseConfig{Name: "ssh"}, LocalPort: 22}
err := store.AddProxy(cfg) Defensive patterns
Strategy: validation
Validate before calling
func namedProxy(cfg *v1.TCPProxyConfig) *v1.TCPProxyConfig {
if strings.TrimSpace(cfg.Name) == "" {
cfg.Name = fmt.Sprintf("tcp-%d", cfg.LocalPort)
}
return cfg
}
// or generic pre-check before Add:
if cfg.GetBaseConfig().Name == "" { return errors.New("proxy name required") } Type guard
func hasProxyName(p v1.ProxyConfigurer) bool {
return p != nil && strings.TrimSpace(p.GetBaseConfig().Name) != ""
} Prevention
- Centralize proxy construction in one factory that always assigns a name
- Validate user-supplied names as required input at the edge (HTTP schema, CLI flag required)
- Add unit tests asserting every programmatically built proxy has a non-empty name
When it happens
Trigger: store.AddProxy(&v1.TCPProxyConfig{...}) where the embedded ProxyBaseConfig.Name was never set; building a configurer via struct literal and forgetting the Name field; copying a template config without filling the name.
Common situations: Programmatic proxy registration code that constructs configs in loops with a name variable that ended up empty; parsing user input where the name field was optional and left blank.
Related errors
- visitor name cannot be empty
- proxy name cannot be empty
- visitor name cannot be empty
- %s name cannot be empty
- ErrInvalidArgument
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/e731de6548e4aa9a.
Report an issue: GitHub.