hyperledger/fabric · error
'%s' not equal <newest|oldest|config|(number)>
Error message
'%s' not equal <newest|oldest|config|(number)>
What it means
osnadmin's fetch command only accepts --channelID block specifiers of 'newest', 'oldest', 'config', or a decimal number. Any other string fails the strconv.Atoi fallback and produces this error before any network call.
Source
Thrown at cmd/osnadmin/main.go:155
switch command {
case join.FullCommand():
resp, err = osnadmin.Join(osnURL, marshaledConfigBlock, caCertPool, tlsClientCert)
case list.FullCommand():
if *listChannelID != "" {
resp, err = osnadmin.ListSingleChannel(osnURL, *listChannelID, caCertPool, tlsClientCert)
break
}
resp, err = osnadmin.ListAllChannels(osnURL, caCertPool, tlsClientCert)
case remove.FullCommand():
resp, err = osnadmin.Remove(osnURL, *removeChannelID, caCertPool, tlsClientCert)
case update.FullCommand():
resp, err = osnadmin.Update(osnURL, marshaledConfigEnvelope, caCertPool, tlsClientCert, *tlsHandshakeTimeShift)
case fetch.FullCommand():
if *fetchBlockID != "newest" && *fetchBlockID != "oldest" && *fetchBlockID != "config" {
_, err = strconv.Atoi(*fetchBlockID)
if err != nil {
return "", 1, fmt.Errorf("'%s' not equal <newest|oldest|config|(number)>", *fetchBlockID)
}
}
resp, err = osnadmin.Fetch(osnURL, *fetchChannelID, *fetchBlockID, caCertPool, tlsClientCert, *tlsHandshakeTimeShift1)
}
if err != nil {
return errorOutput(err), 1, nil
}
bodyBytes, err := readBodyBytes(resp.Body)
if err != nil {
return errorOutput(err), 1, nil
}
output, err = responseOutput(!*noStatus, resp.StatusCode, bodyBytes, *fetchOutputFile)
if err != nil {
return errorOutput(err), 1, nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Use one of the exact keywords: newest, oldest, or config.
- Provide a plain decimal block number (e.g. 5).
- Trim whitespace/quotes from the flag value.
- Check `osnadmin channel fetch --help` for accepted values.
Example fix
// before osnadmin channel fetch latest --channelID mychannel -o orderer:9443 // after osnadmin channel fetch newest --channelID mychannel -o orderer:9443
Defensive patterns
Strategy: validation
Validate before calling
func validFetchTarget(v string) bool {
switch v {
case "newest", "oldest", "config":
return true
}
_, err := strconv.Atoi(v)
return err == nil
}
// call before: if !validFetchTarget(fetchBlockID) { ... } Type guard
func isFetchKeyword(v string) bool {
return v == "newest" || v == "oldest" || v == "config"
} Try / catch
if err := runOsnadmin(); err != nil {
if strings.Contains(err.Error(), "not equal <newest|oldest|config|(number)>") {
log.Fatalf("invalid fetch target %q: use newest|oldest|config|number", err)
}
} Prevention
- Validate the block specifier before invoking fetch.
- Use only documented keywords: newest, oldest, config.
- Quote numeric arguments to avoid shell interpolation surprises.
- Trim whitespace from flag values in wrapper scripts.
When it happens
Trigger: `osnadmin channel fetch` invoked with --channelID values like 'latest', '0x5', '5 ', or a non-numeric block height string.
Common situations: Users familiar with 'latest' from other tools type 'latest' instead of 'newest'; whitespace or quotes accidentally included in the flag value.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- Must supply channel ID
- chaincode path must be specified
- chaincode language must be specified
- output file must be specified
- package label must be specified
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/a08e209fb5aace2f.
Report an issue: GitHub.