{"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/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/bootstrap/bootstrap.go#L654-L690","documentation":"Returned by GetConfiguration when os.ReadFile of the bootstrap file path fails. The path comes from GRPC_XDS_BOOTSTRAP (or the envconfig override). The underlying OS error (not exist, permission denied, etc.) is wrapped.","triggerScenarios":"Triggered at bootstrap.go:672 when bootstrapFileReadFunc(fName) (os.ReadFile) errors. The file does not exist, is not readable, or the path is wrong.","commonSituations":"GRPC_XDS_BOOTSTRAP points to a missing path; in a container the bootstrap file was not mounted/copied; file permissions deny the process; relative path resolved against an unexpected working directory.","solutions":["Confirm GRPC_XDS_BOOTSTRAP is set and the path exists: ls -l $GRPC_XDS_BOOTSTRAP.","In containers/k8s, ensure the ConfigMap/secret holding the bootstrap is mounted at that path.","Check read permissions for the process's UID/GID.","Use an absolute path to avoid working-directory ambiguity."],"exampleFix":"# before\nexport GRPC_XDS_BOOTSTRAP=/etc/grpc-bootstrap.json  # file absent\n\n# after\nexport GRPC_XDS_BOOTSTRAP=/etc/grpc-xds/bootstrap.json\nls -l /etc/grpc-xds/bootstrap.json","handlingStrategy":"validation","validationCode":"// Startup readiness check for the bootstrap file.\nfunc checkBootstrapFile(path string) error {\n    fi, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"bootstrap file: %w\", err)\n    }\n    if fi.Size() == 0 {\n        return fmt.Errorf(\"bootstrap file is empty\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := bootstrap.GetConfiguration(); err != nil {\n    if strings.Contains(err.Error(), \"failed to read bootstrap config from file\") {\n        // fix GRPC_XDS_BOOTSTRAP path/permissions, then restart.\n    }\n}","preventionTips":["Set GRPC_XDS_BOOTSTRAP to an absolute path.","Mount the bootstrap file as a ConfigMap/secret in k8s.","Add a container startup probe that stat()s the file."],"tags":["grpc","xds","bootstrap","filesystem","config","go"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}