{"record":{"id":"5c893b867b41facc","repo":"Tencent/WeKnora","slug":"folder-name-q-must-not-contain-a-path-separator","errorCode":null,"errorMessage":"folder name %q must not contain a path separator","messagePattern":"folder name %q must not contain a path separator","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/application/service/wiki_page.go","lineNumber":1494,"sourceCode":"\t\tfor _, g := range all {\n\t\t\tif g.ID != f.ID && strings.HasPrefix(g.Path, prefix) {\n\t\t\t\tsum += direct[g.ID]\n\t\t\t}\n\t\t}\n\t\tres[f.ID] = sum\n\t}\n\treturn res\n}\n\n// validateFolderName trims and rejects blank names or names carrying directory\n// separators (a folder name is a single tree level).\nfunc validateFolderName(name string) (string, error) {\n\tname = strings.TrimSpace(name)\n\tif name == \"\" {\n\t\treturn \"\", errors.New(\"folder name is required\")\n\t}\n\tif strings.ContainsAny(name, \"/｜|／\") {\n\t\treturn \"\", fmt.Errorf(\"folder name %q must not contain a path separator\", name)\n\t}\n\treturn name, nil\n}\n\n// CreateFolder creates a new empty folder under parentID.\nfunc (s *wikiPageService) CreateFolder(\n\tctx context.Context, kbID string, tenantID uint64, parentID string, name string,\n) (*types.WikiFolder, error) {\n\tname, err := validateFolderName(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tparentPath := \"\"\n\tdepth := 1\n\tif parentID != types.WikiFolderRootID {\n\t\tparent, err := s.repo.GetFolderByID(ctx, kbID, parentID)\n\t\tif err != nil {","sourceCodeStart":1476,"sourceCodeEnd":1512,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_page.go#L1476-L1512","documentation":"validateFolderName rejects folder names containing path separators — '/', '｜', '|', or '／' (fullwidth variants included) — after trimming whitespace, returning 'folder name %q must not contain a path separator'. Folder paths are built by joining names with separators, so embedding one would corrupt the path hierarchy.","triggerScenarios":"CreateFolder or RenameOrMoveFolder with a name like 'a/b', 'docs|archive', or fullwidth 'ａ／ｂ'; pasting file-system or URL paths directly into the folder name field.","commonSituations":"Users pasting 'Projects/2024' from a file explorer into a rename dialog; importing folder trees from CSV where slashes were used as hierarchy hints; locale-specific input methods producing fullwidth slashes.","solutions":["Remove or replace separators in the name (e.g. 'a/b' -> 'a-b' or 'a b').","Express hierarchy via the parent folder / path API instead of separators inside a single name.","Sanitize user input client-side before submission (strip /, |, ／, ｜).","If a slash is intentional content, use a different character like '∕' (division slash) not in the blocked set."],"exampleFix":"// before\nsvc.CreateFolder(ctx, kbID, parentID, \"Projects/2024\")\n// after\nname := strings.ReplaceAll(input, \"/\", \"-\") // \"Projects-2024\"\nsvc.CreateFolder(ctx, kbID, parentID, name)","handlingStrategy":"validation","validationCode":"func sanitizeFolderName(name string) (string, error) {\n    name = strings.TrimSpace(name)\n    if name == \"\" { return \"\", errors.New(\"folder name is required\") }\n    if strings.ContainsAny(name, \"/｜|／\") {\n        return \"\", fmt.Errorf(\"name %q contains a path separator\", name)\n    }\n    return name, nil\n}\n// call before CreateFolder/RenameOrMoveFolder","typeGuard":"func isSafeFolderName(name string) bool {\n    return strings.TrimSpace(name) != \"\" && !strings.ContainsAny(name, \"/｜|／\")\n}","tryCatchPattern":null,"preventionTips":["Sanitize folder name inputs in the UI before submission","Express hierarchy via parent folders, never separators inside a name","Block fullwidth separator variants (｜ ／) for CJK input methods","Validate on rename too — RenameOrMoveFolder uses the same guard"],"tags":["validation","folder","input-sanitization"],"backgroundTag":"invalid-input-validation","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}