{"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":"warning","filePath":"kernel/model/repository.go","lineNumber":1095,"sourceCode":"\t\tfor _, tc := range ret[10:] {\n\t\t\ttc.Count += otherCount\n\t\t}\n\t\tother := &TypeCount{\n\t\t\tType:  \"Other\",\n\t\t\tCount: otherCount,\n\t\t}\n\t\tret = append(ret[:10], other)\n\t}\n\treturn\n}\n\nfunc ImportRepoKey(base64Key string) (retKey string, err error) {\n\tutil.PushMsg(Conf.Language(136), 3000)\n\n\tretKey = gulu.Str.RemoveInvisible(base64Key)\n\tretKey = strings.TrimSpace(retKey)\n\tif 1 > len(retKey) {\n\t\terr = errors.New(Conf.Language(142))\n\t\treturn\n\t}\n\n\tkey, err := base64.StdEncoding.DecodeString(retKey)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"import data repo key failed: %s\", err)\n\t\treturn \"\", errors.New(Conf.Language(157))\n\t}\n\tif 32 != len(key) {\n\t\treturn \"\", errors.New(Conf.Language(157))\n\t}\n\n\tsuspendLANSyncManager()\n\tConf.Repo.Key = key\n\tConf.Save()\n\tlogging.LogInfof(\"imported repo key [%x]\", sha1.Sum(Conf.Repo.Key))\n\n\tif err = os.RemoveAll(Conf.Repo.GetSaveDir()); err != nil {","sourceCodeStart":1077,"sourceCodeEnd":1113,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/repository.go#L1077-L1113","documentation":"ImportRepoKey: after removing invisible chars and trimming whitespace, the base64 key string is empty. The function refuses with i18n key 142 ('Input can not be empty') before attempting any decode. This is a pure input-validation guard.","triggerScenarios":"Calling ImportRepoKey with an empty string, whitespace-only string, or a string consisting solely of invisible/zero-width characters.","commonSituations":"Frontend sent an empty form field; clipboard paste of whitespace; programmatic caller passed an unset variable.","solutions":["Provide a non-empty base64 repo key string exported from a prior 'export data repo key' operation.","Trim and validate the input on the caller side before calling ImportRepoKey."],"exampleFix":"// before\nImportRepoKey(\"\")\n// after\nif strings.TrimSpace(key) == \"\" { return errors.New(\"key required\") }\nImportRepoKey(key)","handlingStrategy":"validation","validationCode":"cleaned := strings.TrimSpace(gulu.Str.RemoveInvisible(base64Key))\nif len(cleaned) == 0 {\n    return \"\", errors.New(model.Conf.Language(142))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable the import button until the field is non-empty.","Trim and validate on the frontend before posting.","Distinguish 'empty' (142) from 'malformed' (157) in the UI message."],"tags":["repo","config","encryption-key","input-validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}