{"record":{"id":"37afffb0af8426fd","repo":"hyperledger/fabric","slug":"filesuffix-s-illegal-cannot-contain-os-path-se","errorCode":null,"errorMessage":"fileSuffix [%s] illegal, cannot contain os path separator","messagePattern":"fileSuffix \\[(.+?)\\] illegal, cannot contain os path separator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/filerepo/filerepo.go","lineNumber":172,"sourceCode":"\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":154,"sourceCodeEnd":177,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/filerepo/filerepo.go#L154-L177","documentation":"validateFileSuffix rejects a fileSuffix containing the OS path separator because suffixes are appended to base names; a separator would let the suffix cross directories, which is unsafe and unsupported. New calls this validation and fails fast.","triggerScenarios":"Calling New with a fileSuffix such as \"a/b\", \"block/\", or a value containing os.PathSeparator (Linux '/' or Windows '\\\\').","commonSituations":"User-supplied configuration where a full path was pasted into a suffix field; building the suffix with filepath.Join instead of a plain string; cross-platform defaults containing backslashes.","solutions":["Strip path separators or pass only the bare extension name (e.g. \"block\", not \"dir/block\")","If a directory component is needed, change the directory passed to New instead of the suffix","Sanitize config input with strings.ReplaceAll(value, string(os.PathSeparator), \"\") before calling New"],"exampleFix":"// before\nrepo, err := filerepo.New(dir, filepath.Join(\"snapshots\", \"snap\"))\n// after\nrepo, err := filerepo.New(filepath.Join(dir, \"snapshots\"), \"snap\")","handlingStrategy":"validation","validationCode":"func validateRepoParams(dir, suffix string) error {\n    if strings.Contains(suffix, string(os.PathSeparator)) {\n        return errors.New(\"fileSuffix must not contain path separators\")\n    }\n    if strings.ContainsAny(suffix, `\\/`) {\n        return errors.New(\"fileSuffix must not contain slashes\")\n    }\n    return nil\n}","typeGuard":"func isSafeSuffix(s string) bool {\n    return len(s) > 0 && !strings.Contains(s, string(os.PathSeparator)) && !strings.Contains(s, \"/\")\n}","tryCatchPattern":"repo, err := filerepo.New(dir, suffix)\nif err != nil && strings.Contains(err.Error(), \"cannot contain os path separator\") {\n    return fmt.Errorf(\"bad fileSuffix %q: use a bare extension name\", suffix)\n}","preventionTips":["Never build suffixes with filepath.Join or os.PathSeparator","Sanitize user-supplied suffix config by stripping separators","Keep the repo dir separate from the suffix naming concern"],"tags":["configuration","validation","path"],"backgroundTag":"invalid-path-characters","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"}