{"record":{"id":"c428bb5f13e4304a","repo":"hyperledger/fabric","slug":"attempted-to-set-the-batch-size-absolute-max-bytes","errorCode":null,"errorMessage":"Attempted to set the batch size absolute max bytes to an invalid value: 0","messagePattern":"Attempted to set the batch size absolute max bytes to an invalid value: 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/channelconfig/orderer.go","lineNumber":219,"sourceCode":"func (oc *OrdererConfig) Validate() error {\n\tfor _, validator := range []func() error{\n\t\toc.validateBatchSize,\n\t\toc.validateBatchTimeout,\n\t} {\n\t\tif err := validator(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (oc *OrdererConfig) validateBatchSize() error {\n\tif oc.protos.BatchSize.MaxMessageCount == 0 {\n\t\treturn fmt.Errorf(\"Attempted to set the batch size max message count to an invalid value: 0\")\n\t}\n\tif oc.protos.BatchSize.AbsoluteMaxBytes == 0 {\n\t\treturn fmt.Errorf(\"Attempted to set the batch size absolute max bytes to an invalid value: 0\")\n\t}\n\tif oc.protos.BatchSize.PreferredMaxBytes == 0 {\n\t\treturn fmt.Errorf(\"Attempted to set the batch size preferred max bytes to an invalid value: 0\")\n\t}\n\tif oc.protos.BatchSize.PreferredMaxBytes > oc.protos.BatchSize.AbsoluteMaxBytes {\n\t\treturn fmt.Errorf(\"Attempted to set the batch size preferred max bytes (%v) greater than the absolute max bytes (%v).\", oc.protos.BatchSize.PreferredMaxBytes, oc.protos.BatchSize.AbsoluteMaxBytes)\n\t}\n\treturn nil\n}\n\nfunc (oc *OrdererConfig) validateBatchTimeout() error {\n\tvar err error\n\toc.batchTimeout, err = time.ParseDuration(oc.protos.BatchTimeout.Timeout)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Attempted to set the batch timeout to a invalid value: %s\", err)\n\t}\n\tif oc.batchTimeout <= 0 {\n\t\treturn fmt.Errorf(\"Attempted to set the batch timeout to a non-positive value: %s\", oc.batchTimeout)","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/channelconfig/orderer.go#L201-L237","documentation":"validateBatchSize requires BatchSize.AbsoluteMaxBytes to be non-zero; AbsoluteMaxBytes caps the total size of a block, and 0 would either disable the cap or make batching meaningless, so the library rejects it during orderer config validation. The check runs whenever an OrdererConfig is validated (NewOrdererConfig/Validate/TestBatchSize).","triggerScenarios":"Calling NewOrdererConfig with an orderer group whose BatchSize value has AbsoluteMaxBytes == 0 — an empty ab.BatchSize struct, a profile missing AbsoluteMaxBytes, or an edit that zeroed the field.","commonSituations":"configtx.yaml Orderer.BatchSize specifying only MaxMessageCount; programmatic config generation leaving AbsoluteMaxBytes unset; test fixtures using ab.BatchSize{}; copying a profile and stripping size fields.","solutions":["Set AbsoluteMaxBytes to a positive value (Fabric default 10485760, i.e. 10 MB) in the Orderer.BatchSize section and regenerate the config.","When building ab.BatchSize in code, set AbsoluteMaxBytes before marshaling into the orderer group values.","Ensure PreferredMaxBytes is also set and remains <= AbsoluteMaxBytes to pass the subsequent checks.","Validate the generated config with configtxlator or configtxgen before submitting the update."],"exampleFix":"// before (configtx.yaml)\nOrderer:\n  BatchSize:\n    MaxMessageCount: 500\n// after\nOrderer:\n  BatchSize:\n    MaxMessageCount: 500\n    AbsoluteMaxBytes: 10 MB\n    PreferredMaxBytes: 2 MB","handlingStrategy":"validation","validationCode":"func checkAbsoluteMaxBytes(bs *ab.BatchSize) error {\n\tif bs == nil || bs.AbsoluteMaxBytes == 0 {\n\t\treturn errors.New(\"BatchSize.AbsoluteMaxBytes must be positive (e.g. 10485760 for 10 MB)\")\n\t}\n\treturn nil\n}","typeGuard":"func hasValidAbsoluteMaxBytes(bs *ab.BatchSize) bool {\n\treturn bs != nil && bs.AbsoluteMaxBytes > 0\n}","tryCatchPattern":"_, err := channelconfig.NewChannelConfig(env.Config)\nif err != nil {\n\tif strings.Contains(err.Error(), \"absolute max bytes to an invalid value: 0\") {\n\t\treturn fmt.Errorf(\"set Orderer.BatchSize.AbsoluteMaxBytes (default 10 MB) in configtx.yaml and regenerate: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Specify AbsoluteMaxBytes explicitly in every Orderer.BatchSize profile (default 10 MB).","Set all three BatchSize fields together so none is left at zero.","Validate the profile with configtxgen before submitting channel updates.","When copying profiles between networks, diff the BatchSize section first."],"tags":["hyperledger-fabric","channel-config","validation","batch-size","configtx"],"backgroundTag":"invalid-config-value","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"}