{"record":{"id":"507664acc3764bf1","repo":"kubernetes/kops","slug":"error-loading-config-file-v","errorCode":null,"errorMessage":"error loading config file: %v","messagePattern":"error loading config file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/swiftfs.go","lineNumber":125,"sourceCode":"\t}\n\n\thomeDir := homedir.HomeDir()\n\tif homeDir == \"\" {\n\t\treturn \"\", fmt.Errorf(\"can not find home directory\")\n\t}\n\tf := filepath.Join(homeDir, \".openstack\", \"config\")\n\tklog.V(2).Infof(\"using openstack config found in %s\", f)\n\treturn f, nil\n}\n\nfunc (oc OpenstackConfig) getSection(name string, items []string) (map[string]string, error) {\n\tfilename, err := oc.filename()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfig, err := ini.Load(filename)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error loading config file: %v\", err)\n\t}\n\tsection, err := config.GetSection(name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting section of %s: %v\", name, err)\n\t}\n\tvalues := make(map[string]string)\n\tfor _, item := range items {\n\t\tvalues[item] = section.Key(item).String()\n\t}\n\treturn values, nil\n}\n\nfunc (oc OpenstackConfig) GetCredential() (gophercloud.AuthOptions, error) {\n\t// prioritize environment config\n\tenv, enverr := openstack.AuthOptionsFromEnv()\n\tif enverr != nil {\n\t\tklog.Warningf(\"Could not initialize OpenStack config from environment: %v\", enverr)\n\t\t// fallback to config file","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/swiftfs.go#L107-L143","documentation":"OpenstackConfig.getSection loads the INI config file resolved by filename() using go-ini's ini.Load. If the file cannot be read or parsed (missing, unreadable permissions, malformed INI), the error is wrapped as 'error loading config file'.","triggerScenarios":"GetRegion, GetServiceConfig, or getCredentialFromFile -> getSection when the config path (from OPENSTACK_CREDENTIAL_FILE or ~/.openstack/config) does not exist, has wrong permissions, or contains invalid INI syntax.","commonSituations":"OPENSTACK_CREDENTIAL_FILE pointing to a nonexistent path, config file with YAML/JSON content instead of INI, duplicate/broken keys, or a permissions issue after copying with root ownership.","solutions":["Verify the resolved path exists and is readable: ls -l $(echo $OPENSTACK_CREDENTIAL_FILE || echo ~/.openstack/config).","Ensure the file is valid INI with [section] headers and key = value lines.","Fix file permissions so the kops process user can read it.","Check the wrapped %v cause for parse errors and fix the offending line."],"exampleFix":"// before (malformed INI)\nGlobal\nregion RegionOne\n// after\n[Global]\nregion = RegionOne","handlingStrategy":"validation","validationCode":"// Pre-validate the INI file parses before invoking the library\nif _, err := ini.Load(configPath); err != nil {\n\treturn fmt.Errorf(\"openstack config %s is not valid INI: %w\", configPath, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the file in strict INI format ([section], key = value)","Fix permissions after copying (readable by the kops user)","Don't write YAML/JSON into OPENSTACK_CREDENTIAL_FILE","Lint the config with `openstack --os-cloud` tooling when available"],"tags":["openstack","ini","config","file"],"backgroundTag":"config-file-load-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}