{"record":{"id":"842e10107a83f09e","repo":"grpc/grpc-go","slug":"xds-failed-to-read-bootstrap-config-from-file-q","errorCode":null,"errorMessage":"xds: failed to read bootstrap config from file %q: %v","messagePattern":"xds: failed to read bootstrap config from file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/bootstrap/bootstrap.go","lineNumber":672,"sourceCode":"//\n// This function tries to process as much of the bootstrap file as possible (in\n// the presence of the errors) and may return a Config object with certain\n// fields left unspecified, in which case the caller should use some sane\n// defaults.\n//\n// This function returns an error if it's unable to parse the contents of the\n// bootstrap config. It returns (nil, nil) if none of the env vars are set.\nfunc GetConfiguration() (*Config, error) {\n\tfName := envconfig.XDSBootstrapFileName\n\tfContent := envconfig.XDSBootstrapFileContent\n\n\tif fName != \"\" {\n\t\tif logger.V(2) {\n\t\t\tlogger.Infof(\"Using bootstrap file with name %q from GRPC_XDS_BOOTSTRAP environment variable\", fName)\n\t\t}\n\t\tcfg, err := bootstrapFileReadFunc(fName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"xds: failed to read bootstrap config from file %q: %v\", fName, err)\n\t\t}\n\t\treturn NewConfigFromContents(cfg)\n\t}\n\n\tif fContent != \"\" {\n\t\tif logger.V(2) {\n\t\t\tlogger.Infof(\"Using bootstrap contents from GRPC_XDS_BOOTSTRAP_CONFIG environment variable\")\n\t\t}\n\t\treturn NewConfigFromContents([]byte(fContent))\n\t}\n\n\treturn nil, nil\n}\n\n// NewConfigFromContents creates a new bootstrap configuration from the provided\n// contents.\nfunc NewConfigFromContents(data []byte) (*Config, error) {\n\t// Normalize the input configuration.","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/bootstrap/bootstrap.go#L654-L690","documentation":"GetConfiguration reads the bootstrap file path from GRPC_XDS_BOOTSTRAP and attempts to os.ReadFile it (bootstrap.go:670-672). If the read itself fails (file does not exist, permission denied, I/O error), this error wraps the OS-level error with the filename so you know which path failed.","triggerScenarios":"Thrown at internal/xds/bootstrap/bootstrap.go:672 when the library encounters an invalid state.","commonSituations":"Mount path mismatch in Kubernetes (the secret/configmap is mounted at a different path); the env var was set but the file creation step in the init container failed; running locally without copying the bootstrap file into the expected location; wrong relative path interpreted against an unexpected working directory.","solutions":["Verify the file exists and is readable: ls -l <path-from-GRPC_XDS_BOOTSTRAP> and run as the same UID.","If running in Kubernetes, check that the ConfigMap/Secret volume mount and the env var path match exactly.","Use an absolute path for GRPC_XDS_BOOTSTRAP to avoid working-directory ambiguity.","Ensure the init container or sidecar that writes the bootstrap file completed successfully before the app container starts."],"exampleFix":"# before: GRPC_XDS_BOOTSTRAP=/etc/grpc-xds/bootstrap.json but file missing\n# after: mount the config and confirm\n#   kubectl exec <pod> -- ls -l /etc/grpc-xds/bootstrap.json","handlingStrategy":"validation","validationCode":"// Verify the bootstrap file is readable before GetConfiguration.\nfunc ensureBootstrapFile(path string) error {\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"bootstrap file %q: %w\", path, err)\n    }\n    if info.IsDir() {\n        return fmt.Errorf(\"bootstrap path %q is a directory\", path)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Wrap GetConfiguration and report the missing file clearly.\ncfg, err := bootstrap.GetConfiguration()\nif err != nil {\n    return fmt.Errorf(\"cannot load xDS bootstrap from GRPC_XDS_BOOTSTRAP=%q: %w\", os.Getenv(\"GRPC_XDS_BOOTSTRAP\"), err)\n}","preventionTips":["Use an absolute path for GRPC_XDS_BOOTSTRAP.","In Kubernetes, add a startup probe that checks the mounted bootstrap file exists and is non-empty.","Ensure the init container or sidecar that writes the file runs to completion first."],"tags":["xds","bootstrap","filesystem","env-var","config","grpc"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}