{"record":{"id":"4063d85cffb0210f","repo":"ipfs/kubo","slug":"reading-config-from-repo-v","errorCode":null,"errorMessage":"reading config from repo (%v)","messagePattern":"reading config from repo \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":782,"sourceCode":"\t\tif oldKey == \"self\" {\n\t\t\treturn fmt.Errorf(\"keystore name for back up cannot be named 'self'\")\n\t\t}\n\t\treturn doRotate(os.Stdout, cctx.ConfigRoot, oldKey, algorithm, nBitsForKeypair, nBitsGiven)\n\t},\n}\n\nfunc doRotate(out io.Writer, repoRoot string, oldKey string, algorithm string, nBitsForKeypair int, nBitsGiven bool) error {\n\t// Open repo\n\trepo, err := fsrepo.Open(repoRoot)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"opening repo (%v)\", err)\n\t}\n\tdefer repo.Close()\n\n\t// Read config file from repo\n\tcfg, err := repo.Config()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading config from repo (%v)\", err)\n\t}\n\n\t// Generate new identity\n\tvar identity config.Identity\n\tif nBitsGiven {\n\t\tidentity, err = config.CreateIdentity(out, []options.KeyGenerateOption{\n\t\t\toptions.Key.Size(nBitsForKeypair),\n\t\t\toptions.Key.Type(algorithm),\n\t\t})\n\t} else {\n\t\tidentity, err = config.CreateIdentity(out, []options.KeyGenerateOption{\n\t\t\toptions.Key.Type(algorithm),\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating identity (%v)\", err)\n\t}\n","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L764-L800","documentation":"After opening the repo, doRotate calls repo.Config() to load the node configuration, which contains the identity being replaced. A failure reading or unmarshalling the config file is wrapped as \"reading config from repo (%v)\". This usually indicates a malformed or unreadable $IPFS_PATH/config.","triggerScenarios":"The config file contains invalid JSON; config file has wrong permissions (unreadable by current user); config file was truncated by an interrupted write; concurrent modification while reading.","commonSituations":"Manual edits to ~/.ipfs/config that broke JSON syntax (trailing commas, unquoted strings); running the command as a different user than the repo owner; disk-full during a previous config write.","solutions":["Validate the JSON: `python3 -m json.tool $IPFS_PATH/config` and fix syntax errors","Check file permissions: `ls -l $IPFS_PATH/config` and chown/chmod as needed","Restore from a backup copy of the config if one exists","If Identity cannot be parsed, back up the file and re-examine it before rotating — rotate needs the old private key"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"python3 -m json.tool \"$IPFS_PATH/config\" > /dev/null && echo \"config OK\" || echo \"config is invalid JSON\"","typeGuard":null,"tryCatchPattern":"if err := doRotate(...); err != nil {\n    if strings.Contains(err.Error(), \"reading config from repo\") {\n        // restore config from backup before retrying\n    }\n}","preventionTips":["Back up $IPFS_PATH/config before manual edits","Never hand-edit config without validating JSON afterwards","Keep consistent ownership/permissions on the repo directory"],"tags":["config","repo","cli"],"backgroundTag":"invalid-config-file","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}