{"record":{"id":"40a18d1a644fcf84","repo":"ipfs/kubo","slug":"failed-to-load-config-q","errorCode":null,"errorMessage":"failed to load config: %q","messagePattern":"failed to load config: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/config.go","lineNumber":581,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to get config value: %q\", err)\n\t}\n\treturn &ConfigField{\n\t\tKey:   key,\n\t\tValue: value,\n\t}, nil\n}\n\nfunc getConfigWithAutoExpand(r repo.Repo, key string) (*ConfigField, error) {\n\t// First get the current value\n\tvalue, err := r.GetConfigKey(key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get config value: %q\", err)\n\t}\n\n\t// Load full config for resolution\n\tfullCfg, err := r.Config()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load config: %q\", err)\n\t}\n\n\t// Expand auto values based on the key\n\texpandedValue := fullCfg.ExpandConfigField(key, value)\n\n\treturn &ConfigField{\n\t\tKey:   key,\n\t\tValue: expandedValue,\n\t}, nil\n}\n\nfunc setConfig(r repo.Repo, key string, value any) (*ConfigField, error) {\n\terr := r.SetConfigKey(key, value)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to set config value: %s (maybe use --json?)\", err)\n\t}\n\treturn getConfig(r, key)\n}","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/config.go#L563-L599","documentation":"Wraps a failure of `r.Config()`, which loads and deserializes the entire repo config. getConfigWithAutoExpand needs the full config to resolve auto-expandable values (like ${IPFS_PATH} placeholders) after reading the raw key. Kubo throws it when the whole config file cannot be loaded, parsed as JSON, or validated against the config schema.","triggerScenarios":"Calling `ipfs config get <key>` when $IPFS_PATH/config.json is missing, unreadable, contains invalid JSON, or fails schema validation (e.g. wrong types in a field).","commonSituations":"Hand-editing config.json and leaving trailing commas or wrong types (e.g. strings where booleans are expected); truncated config after a crash; running as a user without read permission on the repo.","solutions":["Run `ipfs config show` — if it fails too, the config file itself is broken; inspect $IPFS_PATH/config.json with jq to find the JSON syntax error","Restore the config from backup or re-generate defaults (`ipfs init` in a fresh dir and copy relevant fields)","Fix type errors by using `ipfs config --json <key> <value>` instead of hand-editing","Check file permissions/ownership of $IPFS_PATH/config.json"],"exampleFix":"// before (hand-edited config.json)\n{\"Datastore\": {\"StorageMax\": \"10GB\",}}\n// after: fix JSON, or set via CLI\nipfs config --json Datastore.StorageMax \"10GB\"","handlingStrategy":"validation","validationCode":"test -r \"$IPFS_PATH/config\" && jq empty \"$IPFS_PATH/config\" && echo \"config OK\" || echo \"config missing or invalid JSON\"","typeGuard":null,"tryCatchPattern":"cfg, err := r.Config()\nif err != nil {\n    return fmt.Errorf(\"config unreadable: %w\", err)\n}","preventionTips":["Validate config.json with jq after any hand edit","Always set values via `ipfs config --json` instead of editing the file directly","Keep a backup of $IPFS_PATH/config.json before changes","Ensure the repo dir is readable by the user running the daemon/CLI"],"tags":["config","json","repo"],"backgroundTag":"config-file-invalid-json","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"}