fatedier/frp · error · configmgmt.ErrInvalidArgument

invalid argument: visitor name is required

Error message

invalid argument: visitor name is required

What it means

Returned by GetStoreVisitor when the name argument is empty. The visitor store API (GET /api/store/visitors/{name}) requires the visitor's name; an empty identifier fails fast with ErrInvalidArgument before the store source is consulted.

Source

Thrown at client/config_manager.go:263

	}); err != nil {
		return err
	}

	log.Infof("store: deleted proxy %q", name)
	return nil
}

func (m *serviceConfigManager) ListStoreVisitors() ([]v1.VisitorConfigurer, error) {
	storeSource, err := m.storeSourceOrError()
	if err != nil {
		return nil, err
	}
	return storeSource.GetAllVisitors()
}

func (m *serviceConfigManager) GetStoreVisitor(name string) (v1.VisitorConfigurer, error) {
	if name == "" {
		return nil, fmt.Errorf("%w: visitor name is required", configmgmt.ErrInvalidArgument)
	}

	storeSource, err := m.storeSourceOrError()
	if err != nil {
		return nil, err
	}

	cfg := storeSource.GetVisitor(name)
	if cfg == nil {
		return nil, fmt.Errorf("%w: visitor %q", configmgmt.ErrNotFound, name)
	}
	return cfg, nil
}

func (m *serviceConfigManager) CreateStoreVisitor(cfg v1.VisitorConfigurer) (v1.VisitorConfigurer, error) {
	if err := m.validateStoreVisitorConfigurer(cfg); err != nil {
		return nil, fmt.Errorf("%w: validation error: %v", configmgmt.ErrInvalidArgument, err)
	}

View on GitHub (pinned to 6c8a8d0a97)

Solutions

  1. Pass the exact visitor name: GET /api/store/visitors/my-stcp-visitor.
  2. Fix the empty-variable source (env var, JSON field) upstream.
  3. Discover valid names via GET /api/store/visitors.

Example fix

# before
name=""
curl .../api/store/visitors/$name   # 400 visitor name is required

# after
curl .../api/store/visitors/db-visitor
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(name) == "" {
    return errors.New("visitor name must be non-empty")
}
vcfg, err := mgr.GetStoreVisitor(name)

Try / catch

if _, err := mgr.GetStoreVisitor(name); err != nil {
    if errors.Is(err, configmgmt.ErrInvalidArgument) { /* empty name */ }
    if errors.Is(err, configmgmt.ErrNotFound) { /* no such visitor */ }
}

Prevention

When it happens

Trigger: Calling GetStoreVisitor("") directly; a GET request to /api/store/visitors/ where the name segment decodes to empty; URL interpolation with an unset variable.

Common situations: Scripts building URLs by concatenation with empty variables; Go code passing a zero-value name field from a partially populated request struct.

Related errors


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