{"record":{"id":"95a4bb2d75b69aa5","repo":"siyuan-note/siyuan","slug":"the-key-is-not-recognized-please-confirm-that-the","errorCode":null,"errorMessage":"The key is not recognized, please confirm that the copied key string is correct","messagePattern":"The key is not recognized, please confirm that the copied key string is correct","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":1102,"sourceCode":"\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 {\n\t\treturn\n\t}\n\tif err = os.MkdirAll(Conf.Repo.GetSaveDir(), 0755); err != nil {\n\t\treturn\n\t}\n\n\tinitDataRepo()","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/repository.go#L1084-L1120","documentation":"ImportRepoKey: the trimmed input is non-empty but base64.StdEncoding.DecodeString fails (illegal characters / wrong alphabet / bad padding). Returns i18n key 157 ('The key is not recognized...'). The original decode error is logged but not surfaced to the user.","triggerScenarios":"Pasting a key that is not valid standard base64 — e.g. URL-safe base64, hex, a password mistaken for a key, trailing/inserted spaces inside the string, or copy/paste truncation introducing an invalid char.","commonSituations":"User confuses the passphrase with the exported key; key copied from a source that altered characters; URL-safe base64 (- and _) instead of standard (+ and /).","solutions":["Re-copy the exported key exactly; it must be standard base64 with no internal whitespace.","If the key is URL-safe base64, convert it to standard (map - -> +, _ -> /) before importing.","If only a passphrase is available, use InitRepoKeyFromPassphrase instead of ImportRepoKey."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"decoded, err := base64.StdEncoding.DecodeString(cleaned)\nif err != nil {\n    // try URL-safe base64 as a courtesy\n    decoded, err = base64.URLEncoding.DecodeString(cleaned)\n    if err != nil {\n        return \"\", errors.New(model.Conf.Language(157))\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Tell users to paste the exported key exactly, with no internal spaces.","If the source is URL-safe base64, convert to standard first.","Use InitRepoKeyFromPassphrase when only a passphrase is available."],"tags":["repo","config","encryption-key","base64","input-validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}