{"record":{"id":"960d6721a21c1689","repo":"kubernetes/kops","slug":"region-not-provided-in-os-region-name-or-openstack","errorCode":null,"errorMessage":"region not provided in OS_REGION_NAME or openstack config section GLOBAL","messagePattern":"region not provided in OS_REGION_NAME or openstack config section GLOBAL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/swiftfs.go","lineNumber":177,"sourceCode":"\treturn false\n}\n\nfunc (oc OpenstackConfig) GetRegion() (string, error) {\n\tvar region string\n\tif region = os.Getenv(\"OS_REGION_NAME\"); region != \"\" {\n\t\tif len(region) > 1 {\n\t\t\tif region[0] == '\\'' && region[len(region)-1] == '\\'' {\n\t\t\t\tregion = region[1 : len(region)-1]\n\t\t\t}\n\t\t}\n\t\treturn region, nil\n\t}\n\n\titems := []string{\"region\"}\n\t// TODO: Unsure if this is the correct section for region\n\tvalues, err := oc.getSection(\"Global\", items)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"region not provided in OS_REGION_NAME or openstack config section GLOBAL\")\n\t}\n\treturn values[\"region\"], nil\n}\n\nfunc (oc OpenstackConfig) getCredentialFromFile() (gophercloud.AuthOptions, error) {\n\topt := gophercloud.AuthOptions{}\n\tname := \"Default\"\n\titems := []string{\"identity\", \"user\", \"user_id\", \"password\", \"domain_id\", \"domain_name\", \"tenant_id\", \"tenant_name\"}\n\tvalues, err := oc.getSection(name, items)\n\tif err != nil {\n\t\treturn opt, err\n\t}\n\n\tfor _, c1 := range []string{\"identity\", \"password\"} {\n\t\tif values[c1] == \"\" {\n\t\t\treturn opt, fmt.Errorf(\"missing %s in section of %s\", c1, name)\n\t\t}\n\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/swiftfs.go#L159-L195","documentation":"OpenstackConfig.GetRegion determines the Swift region: first from the OS_REGION_NAME env var, otherwise from the 'region' key of the Global section of the openstack config. When neither is available (getSection fails or the values are missing), it returns this descriptive error instead of wrapping the underlying cause.","triggerScenarios":"newDesignate, NewOpenstackCloud, or NewSwiftClient -> GetRegion when OS_REGION_NAME is unset/empty AND the [Global] section is absent or has no 'region' key in the config file.","commonSituations":"Partially populated clouds.yaml-style files copied from other tools, environments where only OS_AUTH_URL/credentials were exported but not the region, multi-region deployments where the user forgot to pick one.","solutions":["export OS_REGION_NAME=<your-region> in the environment.","Add region = <your-region> under the [Global] section of ~/.openstack/config (or OPENSTACK_CREDENTIAL_FILE).","Find your region with: openstack endpoint list and use the region of the object-store endpoint.","If running in CI, add OS_REGION_NAME to the job's secret/env configuration."],"exampleFix":"// before\n[Global]\n// after\n[Global]\nregion = RegionOne","handlingStrategy":"validation","validationCode":"// Ensure a region is resolvable before running openstack-backed kops\nif os.Getenv(\"OS_REGION_NAME\") == \"\" {\n\tif _, err := ini.Load(\"~/.openstack/config\"); err == nil {\n\t\t// still verify [Global].region exists\n\t\t_ = err\n\t}\n\treturn errors.New(\"export OS_REGION_NAME or set region in [Global]\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export OS_REGION_NAME alongside the other OS_* vars","Add region to the [Global] section as a fallback","Discover the region once with `openstack endpoint list` and persist it","Document the required env vars in team CI templates"],"tags":["openstack","region","config","environment"],"backgroundTag":"missing-os-region-name","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"}