{"record":{"id":"23fe916eb379134f","repo":"hyperledger/fabric","slug":"filesuffix-illegal-cannot-be-empty","errorCode":null,"errorMessage":"fileSuffix illegal, cannot be empty","messagePattern":"fileSuffix illegal, cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/filerepo/filerepo.go","lineNumber":168,"sourceCode":"\n// FileToBaseName strips the suffix from the file name to get the associated channel name.\nfunc (r *Repo) FileToBaseName(fileName string) string {\n\tbaseFile := filepath.Base(fileName)\n\n\treturn strings.TrimSuffix(baseFile, \".\"+r.fileSuffix)\n}\n\nfunc (r *Repo) baseToFilePath(baseName string) string {\n\treturn filepath.Join(r.fileRepoDir, r.baseToFileName(baseName))\n}\n\nfunc (r *Repo) baseToFileName(baseName string) string {\n\treturn baseName + \".\" + r.fileSuffix\n}\n\nfunc validateFileSuffix(fileSuffix string) error {\n\tif len(fileSuffix) == 0 {\n\t\treturn errors.New(\"fileSuffix illegal, cannot be empty\")\n\t}\n\n\tif strings.Contains(fileSuffix, string(os.PathSeparator)) {\n\t\treturn errors.Errorf(\"fileSuffix [%s] illegal, cannot contain os path separator\", fileSuffix)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":150,"sourceCodeEnd":177,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/filerepo/filerepo.go#L150-L177","documentation":"validateFileSuffix rejects an empty fileSuffix because Repo builds file names as baseName + \".\" + fileSuffix; an empty suffix would create ambiguous names. New calls this validation and fails fast before touching the filesystem.","triggerScenarios":"Calling New (directly or via a higher-level constructor such as a block repository initializer) with fileSuffix = \"\" in the options/arguments.","commonSituations":"Programmatic construction of a Repo or BlockRepository where the suffix is read from config and the config key is unset or bound to an empty string; accidental clearing of a constant in refactoring.","solutions":["Pass a non-empty fileSuffix to New (e.g. \"block\" or \"snapshot\")","If loaded from configuration, set the corresponding config value or default it in code","Add a startup-time config check so empty suffixes are rejected with a clearer message"],"exampleFix":"// before\nrepo, err := filerepo.New(dir, \"\")\n// after\nrepo, err := filerepo.New(dir, \"block\")","handlingStrategy":"validation","validationCode":"func validateRepoParams(dir, suffix string) error {\n    if suffix == \"\" {\n        return errors.New(\"fileSuffix must be non-empty\")\n    }\n    return nil\n}\n// call before filerepo.New(dir, suffix)","typeGuard":"func hasSuffix(suffix string) bool { return len(suffix) > 0 }","tryCatchPattern":"repo, err := filerepo.New(dir, suffix)\nif err != nil && err.Error() == \"fileSuffix illegal, cannot be empty\" {\n    return fmt.Errorf(\"configuration error: fileSuffix must be set, got %q\", suffix)\n}","preventionTips":["Default the suffix in code rather than reading raw config","Fail config loading early when required string fields are empty","Keep suffixes as constants, not free-form user input"],"tags":["configuration","validation","startup"],"backgroundTag":"missing-config-value","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"}