Tencent/WeKnora · warning

folder name %q must not contain a path separator

Error message

folder name %q must not contain a path separator

What it means

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.

Source

Thrown at internal/application/service/wiki_page.go:1494

		for _, g := range all {
			if g.ID != f.ID && strings.HasPrefix(g.Path, prefix) {
				sum += direct[g.ID]
			}
		}
		res[f.ID] = sum
	}
	return res
}

// validateFolderName trims and rejects blank names or names carrying directory
// separators (a folder name is a single tree level).
func validateFolderName(name string) (string, error) {
	name = strings.TrimSpace(name)
	if name == "" {
		return "", errors.New("folder name is required")
	}
	if strings.ContainsAny(name, "/||/") {
		return "", fmt.Errorf("folder name %q must not contain a path separator", name)
	}
	return name, nil
}

// CreateFolder creates a new empty folder under parentID.
func (s *wikiPageService) CreateFolder(
	ctx context.Context, kbID string, tenantID uint64, parentID string, name string,
) (*types.WikiFolder, error) {
	name, err := validateFolderName(name)
	if err != nil {
		return nil, err
	}

	parentPath := ""
	depth := 1
	if parentID != types.WikiFolderRootID {
		parent, err := s.repo.GetFolderByID(ctx, kbID, parentID)
		if err != nil {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Remove or replace separators in the name (e.g. 'a/b' -> 'a-b' or 'a b').
  2. Express hierarchy via the parent folder / path API instead of separators inside a single name.
  3. Sanitize user input client-side before submission (strip /, |, /, |).
  4. If a slash is intentional content, use a different character like '∕' (division slash) not in the blocked set.

Example fix

// before
svc.CreateFolder(ctx, kbID, parentID, "Projects/2024")
// after
name := strings.ReplaceAll(input, "/", "-") // "Projects-2024"
svc.CreateFolder(ctx, kbID, parentID, name)
Defensive patterns

Strategy: validation

Validate before calling

func sanitizeFolderName(name string) (string, error) {
    name = strings.TrimSpace(name)
    if name == "" { return "", errors.New("folder name is required") }
    if strings.ContainsAny(name, "/||/") {
        return "", fmt.Errorf("name %q contains a path separator", name)
    }
    return name, nil
}
// call before CreateFolder/RenameOrMoveFolder

Type guard

func isSafeFolderName(name string) bool {
    return strings.TrimSpace(name) != "" && !strings.ContainsAny(name, "/||/")
}

Prevention

When it happens

Trigger: CreateFolder or RenameOrMoveFolder with a name like 'a/b', 'docs|archive', or fullwidth 'a/b'; pasting file-system or URL paths directly into the folder name field.

Common situations: 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.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/5c893b867b41facc. Report an issue: GitHub.