hyperledger/fabric · error
unknown rule type '%s', expected ALL, ANY, or MAJORITY
Error message
unknown rule type '%s', expected ALL, ANY, or MAJORITY
What it means
Returned by ImplicitMetaFromString when the first space-separated token of an implicit-meta policy string is not one of ANY, ALL, or MAJORITY — e.g. 'SOME org.admin'. The rule keyword itself is unrecognized, so the policy cannot be compiled to an ImplicitMetaPolicy.
Source
Thrown at common/policies/implicitmetaparser.go:34
func ImplicitMetaFromString(input string) (*cb.ImplicitMetaPolicy, error) {
args := strings.Split(input, " ")
if len(args) != 2 {
return nil, errors.Errorf("expected two space separated tokens, but got %d", len(args))
}
res := &cb.ImplicitMetaPolicy{
SubPolicy: args[1],
}
switch args[0] {
case cb.ImplicitMetaPolicy_ANY.String():
res.Rule = cb.ImplicitMetaPolicy_ANY
case cb.ImplicitMetaPolicy_ALL.String():
res.Rule = cb.ImplicitMetaPolicy_ALL
case cb.ImplicitMetaPolicy_MAJORITY.String():
res.Rule = cb.ImplicitMetaPolicy_MAJORITY
default:
return nil, errors.Errorf("unknown rule type '%s', expected ALL, ANY, or MAJORITY", args[0])
}
return res, nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Use one of the exact uppercase keywords: ALL, ANY, or MAJORITY as the first token
- Correct token order so the rule precedes the sub-policy name ('ANY Readers', not 'Readers ANY')
- Check for case sensitivity issues introduced by templating or generation of the config
Example fix
// before
ImplicitMetaFromString("any Readers")
// after
ImplicitMetaFromString("ANY Readers") Defensive patterns
Strategy: validation
Validate before calling
func validRule(s string) bool {
switch s {
case "ALL", "ANY", "MAJORITY": return true
}
return false
}
first := strings.Fields(input)[0]
// require validRule(first) before ImplicitMetaFromString Try / catch
policy, err := policies.ImplicitMetaFromString(input)
if err != nil && strings.Contains(err.Error(), "unknown rule type") {
return fmt.Errorf("rule must be ALL/ANY/MAJORITY (exact case), got: %v", err)
} Prevention
- Use exact uppercase rule keywords; the parser is case-sensitive
- Keep the rule token first: 'RULE SubPolicy'
- Lint configtx.yaml policy strings against ^(ALL|ANY|MAJORITY) [A-Za-z]+$
When it happens
Trigger: Calling ImplicitMetaFromString with a first token that is not exactly 'ANY', 'ALL', or 'MAJORITY' (case-sensitive), e.g. 'any Readers', 'MOST Admins', or a reversed input like 'Readers ANY'.
Common situations: Lowercase rule keywords in configtx.yaml; accidentally swapping the token order ('Readers ANY'); inventing rule names that the implicit meta parser does not support.
Related errors
- expected two space separated tokens, but got %d
- policy %s at path %s was nil
- implicit policy %s at path %s did not compile
- not a valid hashedDataNs [%s]
- could not parse RevocationList
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/0edd572393deeff0.
Report an issue: GitHub.