{"record":{"id":"ee0e4e490a6e7bf5","repo":"hyperledger/fabric","slug":"s-not-equal-newest-oldest-config-number-ee0e4e","errorCode":null,"errorMessage":"'%s' not equal <newest|oldest|config|(number)>","messagePattern":"'(.+?)' not equal <newest\\|oldest\\|config\\|\\(number\\)>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/channelparticipation/validator.go","lineNumber":125,"sourceCode":"}\n\n// ValidateFetchBlockID checks the block id. He can be: newest|oldest|config|(number)\nfunc ValidateFetchBlockID(blockID string) error {\n\t// Length\n\tif len(blockID) <= 0 {\n\t\treturn errors.Errorf(\"block ID illegal, cannot be empty\")\n\t}\n\n\tif blockID == \"newest\" || blockID == \"oldest\" || blockID == \"config\" {\n\t\treturn nil\n\t}\n\n\t_, err := strconv.Atoi(blockID)\n\tif err == nil {\n\t\treturn nil\n\t}\n\n\treturn errors.Errorf(\"'%s' not equal <newest|oldest|config|(number)>\", blockID)\n}\n","sourceCodeStart":107,"sourceCodeEnd":127,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/channelparticipation/validator.go#L107-L127","documentation":"When the block ID is non-empty but is not one of the accepted keywords and cannot be parsed as an integer, ValidateFetchBlockID rejects it with this formatted error echoing the offending value. It defines the full accepted grammar: newest|oldest|config|(number).","triggerScenarios":"Calling the fetch-block API with values like 'last', 'latest', '0x10', '12.5', 'new ', '-1', or any typo of the keywords.","commonSituations":"Developers guessing the keyword set (using 'latest' instead of 'newest'); passing hex or float numbers; trailing whitespace or hidden characters from copy-paste; localization bugs.","solutions":["Use exactly one of: newest, oldest, config, or a plain base-10 integer string.","Trim the input of whitespace and strip quotes before sending.","Convert hex/other bases to decimal first (e.g. printf '%d' 0x10 -> 16).","Add client-side validation with strconv.Atoi plus keyword check so the request never goes out invalid."],"exampleFix":"// before\nfetchBlock(\"latest\") // not accepted\n// after\nfetchBlock(\"newest\") // or fetchBlock(\"42\")","handlingStrategy":"validation","validationCode":"valid := func(id string) bool {\n    if id == \"newest\" || id == \"oldest\" || id == \"config\" { return true }\n    _, err := strconv.Atoi(strings.TrimSpace(id))\n    return err == nil\n}\nif !valid(blockID) { return fmt.Errorf(\"block ID %q must be newest|oldest|config|number\", blockID) }","typeGuard":null,"tryCatchPattern":"if err := channelparticipation.ValidateFetchBlockID(blockID); err != nil {\n    // surface the server's formatted message listing accepted values\n    return err\n}","preventionTips":["Trim whitespace and strip quotes from user input","Convert hex/float inputs to plain base-10 integers first","Enumerate the accepted keywords in UI dropdowns instead of free text"],"tags":["fabric","orderer","invalid-argument","api"],"backgroundTag":"invalid-parameter-format","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"}