hyperledger/fabric · error
Attempted to set the batch size absolute max bytes to an inv
Error message
Attempted to set the batch size absolute max bytes to an invalid value: 0
What it means
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).
Source
Thrown at common/channelconfig/orderer.go:219
func (oc *OrdererConfig) Validate() error {
for _, validator := range []func() error{
oc.validateBatchSize,
oc.validateBatchTimeout,
} {
if err := validator(); err != nil {
return err
}
}
return nil
}
func (oc *OrdererConfig) validateBatchSize() error {
if oc.protos.BatchSize.MaxMessageCount == 0 {
return fmt.Errorf("Attempted to set the batch size max message count to an invalid value: 0")
}
if oc.protos.BatchSize.AbsoluteMaxBytes == 0 {
return fmt.Errorf("Attempted to set the batch size absolute max bytes to an invalid value: 0")
}
if oc.protos.BatchSize.PreferredMaxBytes == 0 {
return fmt.Errorf("Attempted to set the batch size preferred max bytes to an invalid value: 0")
}
if oc.protos.BatchSize.PreferredMaxBytes > oc.protos.BatchSize.AbsoluteMaxBytes {
return 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)
}
return nil
}
func (oc *OrdererConfig) validateBatchTimeout() error {
var err error
oc.batchTimeout, err = time.ParseDuration(oc.protos.BatchTimeout.Timeout)
if err != nil {
return fmt.Errorf("Attempted to set the batch timeout to a invalid value: %s", err)
}
if oc.batchTimeout <= 0 {
return fmt.Errorf("Attempted to set the batch timeout to a non-positive value: %s", oc.batchTimeout)View on GitHub (pinned to 2736b63f8f)
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.
Example fix
// before (configtx.yaml)
Orderer:
BatchSize:
MaxMessageCount: 500
// after
Orderer:
BatchSize:
MaxMessageCount: 500
AbsoluteMaxBytes: 10 MB
PreferredMaxBytes: 2 MB Defensive patterns
Strategy: validation
Validate before calling
func checkAbsoluteMaxBytes(bs *ab.BatchSize) error {
if bs == nil || bs.AbsoluteMaxBytes == 0 {
return errors.New("BatchSize.AbsoluteMaxBytes must be positive (e.g. 10485760 for 10 MB)")
}
return nil
} Type guard
func hasValidAbsoluteMaxBytes(bs *ab.BatchSize) bool {
return bs != nil && bs.AbsoluteMaxBytes > 0
} Try / catch
_, err := channelconfig.NewChannelConfig(env.Config)
if err != nil {
if strings.Contains(err.Error(), "absolute max bytes to an invalid value: 0") {
return fmt.Errorf("set Orderer.BatchSize.AbsoluteMaxBytes (default 10 MB) in configtx.yaml and regenerate: %w", err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Attempted to set the batch size max message count to an inva
- Attempted to set the batch size preferred max bytes to an in
- Attempted to set the batch size preferred max bytes (%v) gre
- Attempted to set the batch timeout to a non-positive value:
- unexpected missing policy %s for item %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/c428bb5f13e4304a.
Report an issue: GitHub.