hyperledger/fabric · error
Attempted to set the batch size preferred max bytes (%v) gre
Error message
Attempted to set the batch size preferred max bytes (%v) greater than the absolute max bytes (%v).
What it means
Hyperledger Fabric channel configuration validates the orderer BlockSize settings when an orderer config group is created. This error means the config contains a PreferredMaxBytes value larger than AbsoluteMaxBytes, which is logically impossible: the batcher can never prefer more bytes than the absolute cap. validateBatchSize enforces both values are non-zero and that preferred <= absolute before the channel config is accepted.
Source
Thrown at common/channelconfig/orderer.go:225
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)
}
return nil
}
func (oc *OrdererConfig) validateAllOrgsHaveEndpoints() error {
var orgsMissingEndpoints []stringView on GitHub (pinned to 2736b63f8f)
Solutions
- Set Orderer.BatchSize.PreferredMaxBytes to a value <= Orderer.BatchSize.AbsoluteMaxBytes in configtx.yaml
- If you intended bigger preferred batches, raise AbsoluteMaxBytes above it instead
- Regenerate the genesis/config update with configtxgen after fixing the values
Example fix
# before (configtx.yaml) BatchSize: MaxMessageCount: 500 AbsoluteMaxBytes: 4 MB PreferredMaxBytes: 8 MB # after BatchSize: MaxMessageCount: 500 AbsoluteMaxBytes: 10 MB PreferredMaxBytes: 8 MB
Defensive patterns
Strategy: validation
Validate before calling
func validateBatchSize(bs *abconfig.BatchSize) error {
if bs.PreferredMaxBytes == 0 || bs.AbsoluteMaxBytes == 0 {
return fmt.Errorf("batch size values must be non-zero")
}
if bs.PreferredMaxBytes > bs.AbsoluteMaxBytes {
return fmt.Errorf("PreferredMaxBytes (%d) must be <= AbsoluteMaxBytes (%d)", bs.PreferredMaxBytes, bs.AbsoluteMaxBytes)
}
return nil
} Try / catch
if err := validateBatchSize(cfg.Orderer.BatchSize); err != nil {
return fmt.Errorf("invalid orderer config: %w", err)
}
_, err := channelconfig.NewOrdererConfig(ordererGroup, cryptoProvider)
if err != nil {
if strings.Contains(err.Error(), "preferred max bytes") {
// fix configtx BatchSize values before retrying
}
return err
} Prevention
- Keep AbsoluteMaxBytes >= PreferredMaxBytes in every environment's configtx.yaml
- Add a CI lint/check that parses configtx.yaml and asserts BatchSize ordering
- Use fabric-samples defaults as a baseline and change only one value at a time
When it happens
Trigger: Setting Orderer.BatchSize.PreferredMaxBytes to a number greater than Orderer.BatchSize.AbsoluteMaxBytes in configtx.yaml (or via osnadmin/channel participation config update or configtxgen), then generating/validating the channel creation or update transaction.
Common situations: Hand-editing configtx.yaml and swapping the two values; copying a sample config where AbsoluteMaxBytes was lowered (e.g. 10 MB) while PreferredMaxBytes was raised for larger blocks; automated config templating that assigns defaults in the wrong order.
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 timeout to a non-positive value:
- Attempted to set the batch size max message count to an inva
- Attempted to set the batch size absolute max bytes to an inv
- Attempted to set the batch size preferred max bytes to an in
- Attempted to set the batch timeout to a invalid value: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5f30178c9a7b910c.
Report an issue: GitHub.