{"record":{"id":"388af810e4168cd5","repo":"ipfs/kubo","slug":"s-not-found-388af8","errorCode":null,"errorMessage":"%s not found","messagePattern":"(.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"repo/common/common.go","lineNumber":31,"sourceCode":"\n\tparts := strings.Split(key, \".\")\n\tfor i, part := range parts {\n\t\tsofar := strings.Join(parts[:i], \".\")\n\n\t\tmcursor, ok = cursor.(map[string]any)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"%s key is not a map\", sofar)\n\t\t}\n\n\t\tcursor, ok = mcursor[part]\n\t\tif !ok {\n\t\t\t// Construct the current path traversed to print a nice error message\n\t\t\tvar path string\n\t\t\tif len(sofar) > 0 {\n\t\t\t\tpath += sofar + \".\"\n\t\t\t}\n\t\t\tpath += part\n\t\t\treturn nil, fmt.Errorf(\"%s not found\", path)\n\t\t}\n\t}\n\treturn cursor, nil\n}\n\nfunc MapSetKV(v map[string]any, key string, value any) error {\n\tvar ok bool\n\tvar mcursor map[string]any\n\tvar cursor any = v\n\n\tparts := strings.Split(key, \".\")\n\tfor i, part := range parts {\n\t\tmcursor, ok = cursor.(map[string]any)\n\t\tif !ok {\n\t\t\tsofar := strings.Join(parts[:i], \".\")\n\t\t\treturn fmt.Errorf(\"%s key is not a map\", sofar)\n\t\t}\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/common/common.go#L13-L49","documentation":"MapGetKV returns this error when a segment of the dotted key does not exist in the config map at its level. The message contains the full path traversed up to and including the missing segment (e.g. \"Datastore.StorageMax\" missing produces \"X not found\" for the absent part). It is the ordinary \"no such config key\" error for map-based config access.","triggerScenarios":"GetConfigKey with a key that was never set: typos (\"Addresses.APIs\" vs \"Addresses.API\"), probing optional keys that are absent from the on-disk config, keys removed/renamed between versions, or defaults not yet materialized into the map.","commonSituations":"ipfs config get on a missing field; tooling reading optional config (e.g. Autosave, custom plugin sections) that the user never wrote; automation expecting a key introduced in a newer kubo while running an older node.","solutions":["Treat the error as authoritative absence: check errors.Is/string match and fall back to a default value","List available keys (ipfs config show) to verify the exact spelling/casing of the key","Create the key first with MapSetKV/SetConfigKey if it is optional and legitimately absent","Confirm version compatibility: keys added in newer releases do not exist in older configs"],"exampleFix":"// before\nv, err := MapGetKV(cfg, \"Datastore.StorageMax\")\nif err != nil { return err } // fails when key absent\n// after\nv, err := MapGetKV(cfg, \"Datastore.StorageMax\")\nif err != nil {\n    v = \"10GB\" // default when not found\n}","handlingStrategy":"validation","validationCode":"func hasKey(v map[string]any, dotted string) bool {\n    cur := any(v)\n    parts := strings.Split(dotted, \".\")\n    for i, part := range parts {\n        m, ok := cur.(map[string]any)\n        if !ok {\n            return false\n        }\n        cur, ok = m[part]\n        if !ok {\n            return false\n        }\n        _ = i\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"v, err := GetConfigKey(cfg, \"Swarm.RelayService.Enabled\")\nif err != nil && strings.HasSuffix(err.Error(), \"not found\") {\n    v = defaultRelayEnabled // absent key means default\n}","preventionTips":["Verify exact key spelling with ipfs config show before programmatic access","Treat not-found as 'use default' for optional keys instead of failing","Pin minimum kubo versions for keys introduced in newer releases","Set optional keys explicitly so downstream readers never see absence"],"tags":["config","golang","map-traversal"],"backgroundTag":"config-key-not-found","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"}