XTLS/Xray-core · error

empty tag name!

Error message

empty tag name!

What it means

RemoveRule treats an empty tag as a programming error: the removal loop only runs when tag != ", so an empty string can never match anything and is rejected rather than silently succeeding. Tags are the sole selector for rule removal.

Solutions

  1. Supply the exact ruleTag of an existing rule (obtainable from ListRule)
  2. Guard client-side against empty tags before calling RemoveRule
  3. Ensure rules you intend to manage dynamically are configured with ruleTag set

Example fix

// before
r.RemoveRule(rule.GetRuleTag()) // rule had no ruleTag -> ""

// after
// configure rules with explicit ruleTag, then:
r.RemoveRule("my-rule-tag")
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(tag) == "" {
    return fmt.Errorf("ruleTag required for removal")
}

Prevention

When it happens

Trigger: Calling RemoveRule with an empty/zero-value string; protobuf field ruleTag left unset by client code.

Common situations: Clients reading ruleTag from a struct where the field was never populated; UI panels sending empty selections; default-initialized requests.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/dc7e60973cf60634. Report an issue: GitHub.

Appendix: source

Thrown at app/router/router.go:228

// RemoveRule implements routing.Router.
func (r *Router) RemoveRule(tag string) error {
	r.mu.Lock()
	defer r.mu.Unlock()

	newRules := []*Rule{}
	if tag != "" {
		for _, rule := range r.rules {
			if rule.RuleTag != tag {
				newRules = append(newRules, rule)
			} else if rule.Webhook != nil {
				rule.Webhook.Close()
			}
		}
		r.rules = newRules
		return nil
	}
	return errors.New("empty tag name!")
}

// ListRule implements routing.Router
func (r *Router) ListRule() []routing.Route {
	r.mu.Lock()
	defer r.mu.Unlock()
	ruleList := make([]routing.Route, 0)
	for _, rule := range r.rules {
		ruleList = append(ruleList, &Route{
			outboundTag: rule.Tag,
			ruleTag:     rule.RuleTag,
		})
	}
	return ruleList
}

func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, error) {
	// SkipDNSResolve is set from DNS module.

View on GitHub (pinned to 7d214f8b09)