MyCATApache/Mycat-Server · error · IllegalArgumentException

no rule column is found

Error message

no rule column is found

What it means

After validating functionName, RuleConfig's constructor requires a non-null, non-empty rule column. If column is null or length <= 0, IllegalArgumentException("no rule column is found") is thrown — the sharding rule must know which column's values feed the partition algorithm.

Solutions

  1. Add <columns>yourShardingColumn</columns> inside the <rule> element in rule.xml.
  2. Ensure the column value is non-empty and matches a real column of the sharded table.
  3. If constructing RuleConfig programmatically, pass a non-empty column string.

Example fix

// before (rule.xml)
<rule><function>mod-long</function></rule>
// after
<rule><columns>id</columns><function>mod-long</function></rule>
Defensive patterns

Strategy: validation

Validate before calling

if (column == null || column.isEmpty()) throw new IllegalArgumentException("rule columns element required");

Try / catch

try { new RuleConfig(column, fn); } catch (IllegalArgumentException e) { if ("no rule column is found".equals(e.getMessage())) { LOG.error("rule missing <columns>"); } throw e; }

Prevention

When it happens

Trigger: new RuleConfig(null, fn) or new RuleConfig("", fn), typically from a rule.xml <rule> element whose <columns> element is missing or empty.

Common situations: rule.xml rule entry missing <columns>id</columns>; empty columns element; renaming a column in the schema without updating the rule definition.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/d27390efaa7ef6da. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/config/model/rule/RuleConfig.java:45

import java.io.Serializable;

/**
 * 分片规则,column是用于分片的数据库物理字段
 * @author mycat
 */
public class RuleConfig implements Serializable {
	private final String column;
	private final String functionName;
	private AbstractPartitionAlgorithm ruleAlgorithm;

	public RuleConfig(String column, String functionName) {
		if (functionName == null) {
			throw new IllegalArgumentException("functionName is null");
		}
		this.functionName = functionName;
		if (column == null || column.length() <= 0) {
			throw new IllegalArgumentException("no rule column is found");
		}
		this.column = column;
	}

	

	public AbstractPartitionAlgorithm getRuleAlgorithm() {
		return ruleAlgorithm;
	}



	public void setRuleAlgorithm(AbstractPartitionAlgorithm ruleAlgorithm) {
		this.ruleAlgorithm = ruleAlgorithm;
	}



View on GitHub (pinned to 65f8d8beb7)