{"record":{"id":"8fe92f3e6c9e0b7d","repo":"hyperledger/fabric","slug":"expected-two-space-separated-tokens-but-got-d","errorCode":null,"errorMessage":"expected two space separated tokens, but got %d","messagePattern":"expected two space separated tokens, but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/policies/implicitmetaparser.go","lineNumber":19,"sourceCode":"/*\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n*/\n\npackage policies\n\nimport (\n\t\"strings\"\n\n\tcb \"github.com/hyperledger/fabric-protos-go-apiv2/common\"\n\t\"github.com/pkg/errors\"\n)\n\nfunc ImplicitMetaFromString(input string) (*cb.ImplicitMetaPolicy, error) {\n\targs := strings.Split(input, \" \")\n\tif len(args) != 2 {\n\t\treturn nil, errors.Errorf(\"expected two space separated tokens, but got %d\", len(args))\n\t}\n\n\tres := &cb.ImplicitMetaPolicy{\n\t\tSubPolicy: args[1],\n\t}\n\n\tswitch args[0] {\n\tcase cb.ImplicitMetaPolicy_ANY.String():\n\t\tres.Rule = cb.ImplicitMetaPolicy_ANY\n\tcase cb.ImplicitMetaPolicy_ALL.String():\n\t\tres.Rule = cb.ImplicitMetaPolicy_ALL\n\tcase cb.ImplicitMetaPolicy_MAJORITY.String():\n\t\tres.Rule = cb.ImplicitMetaPolicy_MAJORITY\n\tdefault:\n\t\treturn nil, errors.Errorf(\"unknown rule type '%s', expected ALL, ANY, or MAJORITY\", args[0])\n\t}\n\n\treturn res, nil","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/policies/implicitmetaparser.go#L1-L37","documentation":"ImplicitMetaFromString parses strings like 'ANY Readers' into an ImplicitMetaPolicy proto. It splits the input on spaces and requires exactly two tokens (rule + sub-policy name); any other token count throws this error.","triggerScenarios":"Calling ImplicitMetaFromString with a string that does not contain exactly one space-separated pair, e.g. 'READERS', 'ANY Writers extra', or a value with tabs/multiple spaces collapsing incorrectly.","commonSituations":"Typo or omission in channel config policy values like 'MAJORITY' without the sub-policy name; copying a policy string with an accidental extra word; programmatic construction with an empty or trimmed-to-empty input.","solutions":["Supply exactly two space-separated tokens: a rule (ALL/ANY/MAJORITY) and a sub-policy name, e.g. 'ANY Readers'","Trim surrounding whitespace and remove extra spaces/tabs from the policy string","Check the policy value in configtx.yaml or channel update config for typos or missing sub-policy name"],"exampleFix":"// before\nImplicitMetaFromString(\"MAJORITY\")\n// after\nImplicitMetaFromString(\"MAJORITY Admins\")","handlingStrategy":"validation","validationCode":"func validImplicitMeta(s string) bool {\n  parts := strings.Fields(s)\n  return len(parts) == 2 &&\n    (parts[0] == \"ALL\" || parts[0] == \"ANY\" || parts[0] == \"MAJORITY\")\n}\n// call ImplicitMetaFromString only if validImplicitMeta(input)","typeGuard":null,"tryCatchPattern":"policy, err := policies.ImplicitMetaFromString(input)\nif err != nil && strings.Contains(err.Error(), \"expected two space separated tokens\") {\n  return fmt.Errorf(\"invalid implicit meta policy %q: use 'RULE SubPolicy'\", input)\n}","preventionTips":["Always write policies as exactly 'RULE SubPolicy' with single spaces","Trim and normalize whitespace before parsing","Never omit the sub-policy name in configtx policy expressions"],"tags":["hyperledger-fabric","parsing","policy-config"],"backgroundTag":"malformed-policy-string","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}