hyperledger/fabric · error

Must supply channel ID

Error message

Must supply channel ID

What it means

The `peer node rollback` command rolls a channel's ledger back to a given block number and requires both a channel ID and a target block number. If the channelID flag is not supplied, RunE returns this error instead of invoking kvledger.RollbackKVLedger.

Source

Thrown at internal/peer/node/rollback.go:39

func rollbackCmd() *cobra.Command {
	nodeRollbackCmd.ResetFlags()
	flags := nodeRollbackCmd.Flags()
	flags.StringVarP(&channelID, "channelID", "c", common.UndefinedParamValue, "Channel to rollback.")
	flags.Uint64VarP(&blockNumber, "blockNumber", "b", 0, "Block number to which the channel needs to be rolled back to.")

	return nodeRollbackCmd
}

var nodeRollbackCmd = &cobra.Command{
	Use:   "rollback",
	Short: "Rolls back a channel.",
	Long: "Rolls back a channel to a specified block number. When the command is executed, the peer must be offline." +
		" When the peer starts after the rollback, it will receive blocks, which got removed during the rollback," +
		" from an orderer or another peer to rebuild the block store and state database." +
		" The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.",
	RunE: func(cmd *cobra.Command, args []string) error {
		if channelID == common.UndefinedParamValue {
			return errors.New("Must supply channel ID")
		}

		config := ledgerConfig()
		return kvledger.RollbackKVLedger(config.RootFSPath, channelID, blockNumber)
	},
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Re-run with both flags: `peer node rollback -c <channelID> -b <blockNumber>` (peer offline).
  2. Verify --channelID spelling and that the value is not empty in scripts.
  3. Remember the peer must be offline and must not host snapshot-bootstrapped channels; validate preconditions before retrying.

Example fix

// before
peer node rollback --blockNumber 1000
// after
peer node rollback -c mychannel --blockNumber 1000
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$CHANNEL" ] || [ -z "$BLOCK" ]; then echo "usage: peer node rollback -c <channelID> -b <blockNumber>" >&2; exit 1; fi
peer node rollback -c "$CHANNEL" -b "$BLOCK"

Try / catch

if err := runRollback(); err != nil && err.Error() == "Must supply channel ID" {
    return fmt.Errorf("usage: peer node rollback -c <channelID> --blockNumber N")
}

Prevention

When it happens

Trigger: Running `peer node rollback` without --channelID / -c (even if --blockNumber is provided).

Common situations: Rolling back after a ledger corruption or fork and forgetting -c; automating rollback across peers where the channel variable is empty; flag typos in runbooks.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/a9379d5ded341ae5. Report an issue: GitHub.