{"record":{"id":"df9d14d92df5c6af","repo":"ipfs/kubo","slug":"no-peer-id-in-config-was-ipfs-init-run","errorCode":null,"errorMessage":"no peer ID in config! (was 'ipfs init' run?)","messagePattern":"no peer ID in config! \\(was 'ipfs init' run\\?\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/node/groups.go","lineNumber":276,"sourceCode":"\t\t\tcacheOpts,\n\t\t\tcfg.Datastore.HashOnRead,\n\t\t\tcfg.Datastore.WriteThrough.WithDefault(config.DefaultWriteThrough),\n\t\t\tcfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy),\n\t\t)),\n\t\tfinalBstore,\n\t)\n}\n\n// Identity groups units providing cryptographic identity\nfunc Identity(cfg *config.Config) fx.Option {\n\t// PeerID\n\n\tcid := cfg.Identity.PeerID\n\tif cid == \"\" {\n\t\treturn fx.Error(errors.New(\"identity was not set in config (was 'ipfs init' run?)\"))\n\t}\n\tif len(cid) == 0 {\n\t\treturn fx.Error(errors.New(\"no peer ID in config! (was 'ipfs init' run?)\"))\n\t}\n\n\tid, err := peer.Decode(cid)\n\tif err != nil {\n\t\treturn fx.Error(fmt.Errorf(\"peer ID invalid: %s\", err))\n\t}\n\n\t// Private Key\n\n\tif cfg.Identity.PrivKey == \"\" {\n\t\treturn fx.Options( // No PK (usually in tests)\n\t\t\tfx.Provide(PeerID(id)),\n\t\t\tfx.Provide(libp2p.Peerstore),\n\t\t)\n\t}\n\n\tsk, err := cfg.Identity.DecodePrivateKey(\"passphrase todo!\")\n\tif err != nil {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/node/groups.go#L258-L294","documentation":"Defensive duplicate check for the same Identity section: after the empty-string check, a non-empty-but-zero-length PeerID (impossible in practice via the same field, but guarded for safety) also fails node construction. Same root cause and remedy as the \"identity was not set\" error: the repo has no usable peer identity.","triggerScenarios":"`len(cid) == 0` after `cid != \"\"` passed — effectively a parallel guard in Identity(cfg); reachable only through unusual config states or programmatic config construction with a nil/empty PeerID variant.","commonSituations":"Programmatically constructed config.Config structs (e.g. kubo-as-a-library users) leaving Identity.PeerID as its zero value; partially deserialized configs.","solutions":["Initialize Identity.PeerID to a valid peer ID before building the node (library use)","Run `ipfs init` for CLI/daemon use","Review code that builds config.Config programmatically — this guard suggests a struct built with an empty Identity"],"exampleFix":"// before (library code)\ncfg := &config.Config{} // Identity unset\n// after\ncfg := &config.Config{ Identity: config.Identity{ PeerID: peerIDStr, PrivKey: keyStr } }","handlingStrategy":"validation","validationCode":"if cfg.Identity == nil || len(cfg.Identity.PeerID) == 0 {\n\treturn errors.New(\"config.Identity.PeerID must be a non-empty peer ID\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When building config.Config in library code, always populate Identity explicitly","Validate configs with peer.Decode before use","Never serialize/deserialize config structs into a lossy format"],"tags":["config","identity","initialization"],"backgroundTag":"missing-identity-config","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"}