{"record":{"id":"97994a7f456ebac9","repo":"siyuan-note/siyuan","slug":"conf-language-151","errorCode":null,"errorMessage":"Conf.Language(151)","messagePattern":"Conf\\.Language\\(151\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/repository.go","lineNumber":1653,"sourceCode":"\terr = repo.RemoveTag(tag)\n\treturn\n}\n\nfunc TagSnapshot(id, name string) (err error) {\n\tif 1 > len(Conf.Repo.Key) {\n\t\terr = errors.New(Conf.Language(26))\n\t\treturn\n\t}\n\n\tname = util.RemoveInvalid(name)\n\tname = strings.TrimSpace(name)\n\tif \"\" == name {\n\t\terr = errors.New(Conf.Language(142))\n\t\treturn\n\t}\n\n\tif !gulu.File.IsValidFilename(name) {\n\t\terr = errors.New(Conf.Language(151))\n\t\treturn\n\t}\n\n\trepo, err := newRepository()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tindex, err := repo.GetIndex(id)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif err = repo.AddTag(index.ID, name); err != nil {\n\t\tmsg := fmt.Sprintf(\"Add tag to data snapshot [%s] failed: %s\", index.ID, err)\n\t\tutil.PushStatusBar(msg)\n\t\treturn\n\t}","sourceCodeStart":1635,"sourceCodeEnd":1671,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/repository.go#L1635-L1671","documentation":"The TagSnapshot function rejects a tag name that fails the gulu.File.IsValidFilename check, meaning it contains characters invalid for filesystem filenames (e.g., path separators, null bytes, or OS-reserved names on Windows like CON, PRN). The Language(151) string is the 'invalid filename' message. This guard fires after the empty-name check.","triggerScenarios":"Calling TagSnapshot(id, name) where the name contains characters like forward slashes, backslashes, colons, asterisks, question marks, angle brackets, pipe characters, or is a reserved filename on the target OS. The gulu.File.IsValidFilename function performs platform-aware validation.","commonSituations":"A user includes special characters in a tag name (e.g., 'feature/v2', 'backup:2024', 'Q&A'). On Windows, names like 'CON' or 'LPT1' are reserved. This is common when tag names are auto-generated from content that includes punctuation.","solutions":["Remove or replace invalid filename characters from the tag name before calling TagSnapshot","Use alphanumeric characters, hyphens, and underscores as a safe naming convention","Run the name through gulu.File.IsValidFilename on the client side before submitting"],"exampleFix":"// before\nmodel.TagSnapshot(id, \"feature/v2:final\")\n\n// after\nname = strings.Map(func(r rune) rune {\n    if gulu.File.IsValidFilename(string(r)) {\n        return r\n    }\n    return '-'\n}, name)\nmodel.TagSnapshot(id, name)","handlingStrategy":"validation","validationCode":"// Validate filename before calling TagSnapshot\nif !gulu.File.IsValidFilename(name) {\n    return errors.New(\"tag name contains invalid characters\")\n}","typeGuard":"// Check if a string is a valid filename for tagging\nfunc isValidTagName(name string) bool {\n    name = strings.TrimSpace(name)\n    if name == \"\" {\n        return false\n    }\n    return gulu.File.IsValidFilename(name)\n}","tryCatchPattern":null,"preventionTips":["Run client-side filename validation that mirrors gulu.File.IsValidFilename","Provide visual feedback (red border, error tooltip) when the user enters invalid characters","Suggest a sanitized version of the name (e.g., replacing slashes with hyphens) as an auto-fix"],"tags":["validation","filename","snapshot","input"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}