{"record":{"id":"97994a7f456ebac9","repo":"siyuan-note/siyuan","slug":"conf-language-151","errorCode":null,"errorMessage":"Conf.Language(151)","messagePattern":"Conf\\.Language\\(151\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":1720,"sourceCode":"}\n\nfunc TagSnapshot(id, name string) (err error) {\n\tassetDownloadSourceMu.RLock()\n\tdefer assetDownloadSourceMu.RUnlock()\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 := newRepositoryWithAssetSourceLocked()\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":1702,"sourceCodeEnd":1738,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/repository.go#L1702-L1738","documentation":"SiYuan's CreateSnapshotFromMarkedDocument-style repo API rejects a snapshot/repo name that contains filesystem-unsafe characters. The kernel validates the user-supplied name with gulu.File.IsValidFilename and returns a localized message (i18n key 151: \"Do not include symbols \\\\ / : * ? \" ' < > |\") instead of panicking. This is a client-input validation guard before touching the repository.","triggerScenarios":"Calling the kernel API (e.g. /api/repo/createRepoFromRemote or snapshot creation endpoints that take a name parameter) with a name containing \\ / : * ? \" ' < > |, or an empty name (which instead hits key 142).","commonSituations":"Users typing snapshot/repo names copied from Windows paths or URLs; automated scripts generating names with timestamps like '2026/09/11'; names pasted with quotes or angle brackets from HTML.","solutions":["Remove the illegal characters \\ / : * ? \" ' < > | from the name parameter before calling the API.","Sanitize programmatically by stripping everything outside letters, digits, hyphens, underscores and CJK characters.","Retry the request with a plain descriptive name such as a date string like '2026-09-11'."],"exampleFix":"// before\nawait fetchPost('/api/repo/createRepoNotebookSnapshot', {name: 'docs/backup: v1'});\n// after\nconst safeName = rawName.replace(/\\\\/:*?\"'<>|/g, '-');\nawait fetchPost('/api/repo/createRepoNotebookSnapshot', {name: safeName});","handlingStrategy":"validation","validationCode":"const INVALID = /[\\\\/:*?\"'<>|]/;\nif (!name || INVALID.test(name)) {\n  throw new Error('Snapshot name contains illegal characters: \\\\ / : * ? \" \\' < > |');\n}","typeGuard":"const isValidRepoName = (n) => typeof n === 'string' && n.length > 0 && !/[\\\\/:*?\"'<>|]/.test(n);","tryCatchPattern":null,"preventionTips":["Sanitize user-provided names at input time, not at API-call time.","Replace path separators and Windows-reserved characters with hyphens before sending.","Never pass raw file paths or URLs as snapshot names."],"tags":["validation","filename","sync","input"],"backgroundTag":"invalid-argument-value","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}