{"record":{"id":"274ba0d4ab9857e7","repo":"siyuan-note/siyuan","slug":"conf-language-142","errorCode":null,"errorMessage":"Conf.Language(142)","messagePattern":"Conf\\.Language\\(142\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":1090,"sourceCode":"\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\trelease := lockAssetSourceChange()\n\tdefer release()\n\tif err = requireCompleteAssetDownloads(); err != nil {\n\t\treturn\n\t}\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\tif err = clearAssetDownloadState(); err != nil {\n\t\treturn\n\t}\n\n\tsuspendLANSyncManager()\n\tConf.Repo.Key = key\n\tConf.Save()","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L1072-L1108","documentation":"ImportRepoKey imports an existing data repo key from a base64 string. Before decoding it strips invisible characters and whitespace; if nothing remains it returns localized error 142, indicating the provided key string is empty.","triggerScenarios":"Calling ImportRepoKey with a base64 key that is empty or consists only of whitespace/invisible characters after trimming.","commonSituations":"User pasted an empty clipboard; input field left blank in the import-key dialog; copying failed so only invisible characters were transferred.","solutions":["Provide a non-empty base64-encoded 32-byte repo key string","Copy the key again from the source device and retry the import","Guard the call by trimming and length-checking the input before invoking"],"exampleFix":"// before\nmodel.ImportRepoKey(userInput)\n// after\ntrimmed := strings.TrimSpace(userInput)\nif trimmed == \"\" {\n    return errors.New(\"repo key is required\")\n}\nmodel.ImportRepoKey(trimmed)","handlingStrategy":"validation","validationCode":"key := strings.TrimSpace(gulu.Str.RemoveInvisible(input))\nif key == \"\" {\n    return errors.New(\"repo key must not be empty\")\n}\nmodel.ImportRepoKey(key)","typeGuard":null,"tryCatchPattern":"if _, err := model.ImportRepoKey(input); err != nil {\n    return fmt.Errorf(\"import repo key: %w\", err)\n}","preventionTips":["Validate clipboard content before pasting into the import dialog","Never submit the import form with an empty key field","Re-copy the key if the paste looks blank"],"tags":["repo","validation","input"],"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"}