XTLS/Xray-core · error

unknown action:

Error message

unknown action: 

What it means

Thrown by FreedomFinalRuleConfig.Build when the final rule's action field is neither 'allow' nor 'block' (case-insensitive). Final rules are a terminal allow/block decision for freedom traffic, so only those two actions exist; the action is required. Note the error uses errors.New with two args, so the message includes the offending action value after the prefix.

Source

Thrown at infra/conf/freedom.go:261

		NConfig.ApplyTo = "ipv4"
	case "ipv6":
		NConfig.ApplyTo = "ipv6"
	default:
		return nil, errors.New("Invalid applyTo, only ip/ipv4/ipv6 are supported")
	}
	return NConfig, nil
}

func (c *FreedomFinalRuleConfig) Build() (*freedom.FinalRuleConfig, error) {
	rule := &freedom.FinalRuleConfig{}

	switch strings.ToLower(c.Action) {
	case "allow":
		rule.Action = freedom.RuleAction_Allow
	case "block":
		rule.Action = freedom.RuleAction_Block
	default:
		return nil, errors.New("unknown action: ", c.Action)
	}

	if c.Network != nil {
		rule.Networks = c.Network.Build()
	}

	if c.Port != nil {
		rule.PortList = c.Port.Build()
	}

	if c.IP != nil {
		rules, err := geodata.ParseIPRules(*c.IP)
		if err != nil {
			return nil, err
		}
		rule.Ip = rules
	}

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Set the final rule's action to exactly "allow" or "block" (any casing; it is lowercased before matching)
  2. Remove the final rule entry entirely if you do not need an explicit terminal decision

Example fix

// before
"final": [ { "action": "reject" } ]
// after
"final": [ { "action": "block" } ]
Defensive patterns

Strategy: validation

Validate before calling

func validFinalAction(a string) bool {
	s := strings.ToLower(a)
	return s == "allow" || s == "block"
}

Prevention

When it happens

Trigger: Setting settings.final[].action to values like "deny", "reject", "pass", "route", or omitting it entirely (empty string falls into default).

Common situations: Users familiar with routing rule actions (e.g. 'reject') assuming the same vocabulary applies to freedom final rules; forgetting that a final rule with no action is invalid rather than defaulting to allow.

Related errors


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