{"record":{"id":"1e142427b22489af","repo":"hyperledger/fabric","slug":"malformed-org-definition-for-org-s","errorCode":null,"errorMessage":"malformed org definition for org: %s","messagePattern":"malformed org definition for org: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/configtxgen/main.go","lineNumber":131,"sourceCode":"\t\treturn fmt.Errorf(\"malformed transaction contents: %s\", err)\n\t}\n\n\treturn nil\n}\n\nfunc doPrintOrg(t *genesisconfig.TopLevel, printOrg string) error {\n\tfor _, org := range t.Organizations {\n\t\tif org.Name == printOrg {\n\t\t\tif len(org.OrdererEndpoints) > 0 {\n\t\t\t\t// An Orderer OrgGroup\n\t\t\t\tchannelCapabilities := t.Capabilities[\"Channel\"]\n\t\t\t\tog, err := encoder.NewOrdererOrgGroup(org, channelCapabilities)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"bad org definition for org %s\", org.Name)\n\t\t\t\t}\n\n\t\t\t\tif err := protolator.DeepMarshalJSON(os.Stdout, &ordererext.DynamicOrdererOrgGroup{ConfigGroup: og}); err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"malformed org definition for org: %s\", org.Name)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// Otherwise assume it is an Application OrgGroup, where the encoder is not strict whether anchor peers exist or not\n\t\t\tag, err := encoder.NewApplicationOrgGroup(org)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"bad org definition for org %s\", org.Name)\n\t\t\t}\n\t\t\tif err := protolator.DeepMarshalJSON(os.Stdout, &peerext.DynamicApplicationOrgGroup{ConfigGroup: ag}); err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"malformed org definition for org: %s\", org.Name)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn errors.Errorf(\"organization %s not found\", printOrg)\n}\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/configtxgen/main.go#L113-L149","documentation":"In `doPrintOrg` (cmd/configtxgen/main.go:131), the Orderer org group was built successfully by `encoder.NewOrdererOrgGroup`, but `protolator.DeepMarshalJSON` failed to render the resulting `DynamicOrdererOrgGroup` config group as JSON. This means the org's config group contains fields that violate the proto schema or dynamic validation rules enforced by protolator. It is a rendering/validation failure, not a config-parsing failure.","triggerScenarios":"Running `configtxgen -printOrg <org>` where the org resolves to an Orderer org whose generated ConfigGroup fails protolator's deep JSON marshaling (e.g. inconsistent sub-group structure, invalid nested field types, or a bad value that passed the encoder but fails proto dynamic validation).","commonSituations":"Hand-edited or tool-generated configtx.yaml with subtly malformed org fields; org definitions migrated from older Fabric versions whose nested group structure no longer marshals cleanly; corrupted intermediate config produced by an upstream tool.","solutions":["Inspect the wrapped inner error printed alongside this message to find the exact field that failed deep JSON marshaling.","Fix the org definition in configtx.yaml (OrdererOrgs section) so it conforms to the expected schema (correct MSPDir/OUs/Endpoint fields).","Regenerate the org group with a clean configtx.yaml rather than hand-editing intermediate JSON.","If migrating from an older Fabric version, re-validate the org config against the current encoder (encoder.NewOrdererOrgGroup) expectations."],"exampleFix":"// configtx.yaml before (malformed Orderer org)\nOrdererOrgs:\n  - Name: OrdererOrg\n    Domain: example.com\n    Endpoint:   # invalid/misspelled nested field can break deep marshaling\n      - badField: x\n// after\nOrdererOrgs:\n  - Name: OrdererOrg\n    Domain: example.com\n    EnableNodeOUs: true\n    Specs:\n      - Hostname: orderer","handlingStrategy":"validation","validationCode":"// Validate the org resolves and its Orderer group marshals before printing\nog, err := encoder.NewOrdererOrgGroup(org, channelCapabilities)\nif err != nil {\n\treturn fmt.Errorf(\"org %s invalid for orderer encoding: %w\", org.Name, err)\n}\nif err := protolator.DeepMarshalJSON(io.Discard, &ordererext.DynamicOrdererOrgGroup{ConfigGroup: og}); err != nil {\n\treturn fmt.Errorf(\"org %s fails JSON marshaling: %w\", org.Name, err)\n}","typeGuard":null,"tryCatchPattern":"// Go: check and wrap the underlying cause\nif err := protolator.DeepMarshalJSON(os.Stdout, &ordererext.DynamicOrdererOrgGroup{ConfigGroup: og}); err != nil {\n\tlog.Fatalf(\"org %s: %v\", org.Name, errors.Unwrap(err))\n}","preventionTips":["Never hand-edit intermediate config JSON; edit configtx.yaml and regenerate.","Keep configtx.yaml org fields within the documented schema.","Match configtxgen version to your Fabric network version.","Dry-run DeepMarshalJSON to a discard writer in CI to catch malformed orgs early."],"tags":["hyperledger-fabric","configtxgen","protobuf","json-marshaling"],"backgroundTag":"proto-json-marshaling-failed","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"}