{"record":{"id":"4117c031e12b43df","repo":"siyuan-note/siyuan","slug":"input-can-not-be-empty","errorCode":null,"errorMessage":"Input can not be empty","messagePattern":"Input can not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":1728,"sourceCode":"\t\treturn\n\t}\n\n\terr = repo.RemoveTag(tag)\n\treturn\n}\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","sourceCodeStart":1710,"sourceCodeEnd":1746,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L1710-L1746","documentation":"TagSnapshot validates the user-supplied tag name: after removing invalid characters (util.RemoveInvalid) and trimming spaces, an empty string yields errors.New(Conf.Language(142)) ('Input can not be empty'). The check exists because an empty tag name cannot identify a snapshot tag in the encrypted index.","triggerScenarios":"Calling TagSnapshot with a name consisting only of characters stripped by util.RemoveInvalid (e.g. symbols, path separators) or only whitespace, so the sanitized name becomes \"\" and the Language 142 error is returned.","commonSituations":"Frontend submits an empty tag input; automation passes a name built from a title that is entirely punctuation; whitespace-only name from a form that only trim-checks client-side after the kernel already stripped symbols.","solutions":["Pass a non-empty tag name containing letters/digits to TagSnapshot","Sanitize the input yourself before calling: strip invalid characters, trim, and reject empty results client-side with a clear prompt","If the desired name collapses to empty after sanitization, choose a different name — do not retry with the same value","Check Conf.Language(142) text in the error to distinguish this validation failure from the repo-key (Language 26) and symbol (Language 151) errors"],"exampleFix":"// before\nname := docTitle // may be \"---\" or \"   \"\nmodel.TagSnapshot(id, name)\n// after\nname := util.RemoveInvalid(docTitle)\nname = strings.TrimSpace(name)\nif name == \"\" {\n    return errors.New(\"snapshot tag name can not be empty\")\n}\nmodel.TagSnapshot(id, name)","handlingStrategy":"validation","validationCode":"function validateTagName(raw) {\n  const name = raw.replace(/[\\\\/:*?\"'<>|]/g, '').trim();\n  if (!name) throw new Error('Snapshot tag name can not be empty');\n  return name;\n}","typeGuard":null,"tryCatchPattern":"try {\n    await fetchPost('/api/repo/tagSnapshot', {id, name});\n} catch (e) {\n    if (e.msg === 'Input can not be empty') focusNameInputWithPrompt();\n}","preventionTips":["Trim and sanitize the tag name in the UI before submission","Reject inputs that consist only of symbols or whitespace with an inline message","Do not derive tag names from titles that may be entirely punctuation without a fallback name","Test with edge-case inputs (spaces only, symbols only, empty string)"],"tags":["validation","input","snapshot","empty-string"],"backgroundTag":"empty-required-field","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}