{"record":{"id":"ba3ecb29d298fcf8","repo":"ipfs/kubo","slug":"expand-auto-can-only-be-used-for-reading-config","errorCode":null,"errorMessage":"--expand-auto can only be used for reading config values, not for setting them","messagePattern":"--expand-auto can only be used for reading config values, not for setting them","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/config.go","lineNumber":115,"sourceCode":"\t\t// Temporary fix until we move ApiKey secrets out of the config file\n\t\t// (remote services are a map, so more advanced blocking is required)\n\t\tif blocked := matchesGlobPrefix(key, config.PinningConcealSelector); blocked {\n\t\t\treturn errors.New(\"cannot show or change pinning services credentials\")\n\t\t}\n\n\t\tcfgRoot, err := cmdenv.GetConfigRoot(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tr, err := fsrepo.Open(cfgRoot)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer r.Close()\n\t\tif len(args) == 2 {\n\t\t\t// Check if user is trying to write config with expand flag\n\t\t\tif expandAuto, _ := req.Options[configExpandAutoName].(bool); expandAuto {\n\t\t\t\treturn fmt.Errorf(\"--expand-auto can only be used for reading config values, not for setting them\")\n\t\t\t}\n\n\t\t\tvalue := args[1]\n\n\t\t\t// Identity.PeerID is derived from Identity.PrivKey; the node\n\t\t\t// refuses to start when they disagree. Accept only the node's own\n\t\t\t// PeerID in any standard form (base58 or CIDv1), compare decoded\n\t\t\t// IDs rather than strings, store the canonical base58 string kubo\n\t\t\t// writes elsewhere, and point a mismatched value at the supported\n\t\t\t// way to change the identity.\n\t\t\tif strings.EqualFold(key, \"identity.peerid\") {\n\t\t\t\tcandidate := value\n\t\t\t\tif parseJSON, _ := req.Options[configJSONOptionName].(bool); parseJSON {\n\t\t\t\t\tvar s string\n\t\t\t\t\tif err := json.Unmarshal([]byte(value), &s); err == nil {\n\t\t\t\t\t\tcandidate = s\n\t\t\t\t\t}\n\t\t\t\t}","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/config.go#L97-L133","documentation":"'ipfs config' was called with two arguments (a key and a value, i.e. a write) while the --expand-auto flag was set. --expand-auto resolves 'auto' placeholders via AutoConf and is only meaningful for reads; applying expanded values back would overwrite the placeholders permanently.","triggerScenarios":"Thrown at core/commands/config.go:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop --expand-auto when setting a value","Use --expand-auto only with single-argument reads: 'ipfs config --expand-auto <key>'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}