{"record":{"id":"fc8dfb37dacd53f2","repo":"hyperledger/fabric","slug":"error-reading-connection-profile","errorCode":null,"errorMessage":"error reading connection profile","messagePattern":"error reading connection profile","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/common/networkconfig.go","lineNumber":165,"sourceCode":"}\n\n// TLSKeyPair contains the private key and certificate for TLS encryption\n// not currently used by CLI\ntype TLSKeyPair struct {\n\tKey  TLSConfig `yaml:\"key\"`\n\tCert TLSConfig `yaml:\"cert\"`\n}\n\n// GetConfig unmarshals the provided connection profile into a network\n// configuration struct\nfunc GetConfig(fileName string) (*NetworkConfig, error) {\n\tif fileName == \"\" {\n\t\treturn nil, errors.New(\"filename cannot be empty\")\n\t}\n\n\tdata, err := os.ReadFile(fileName)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error reading connection profile\")\n\t}\n\n\tconfigData := string(data)\n\tconfig := &NetworkConfig{}\n\terr = yaml.Unmarshal([]byte(configData), &config)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error unmarshalling YAML\")\n\t}\n\n\treturn config, nil\n}\n","sourceCodeStart":147,"sourceCodeEnd":177,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/common/networkconfig.go#L147-L177","documentation":"GetConfig loads a Hyperledger Fabric connection profile YAML from disk into a NetworkConfig struct. This error wraps any failure from os.ReadFile, meaning the connection profile file could not be read. It is thrown before any YAML parsing happens, so the profile contents are irrelevant.","triggerScenarios":"Calling GetConfig (directly or via peer commands that call validatePeerConnectionParameters / parseConnectionProfile) with an empty-derived file path that exists check fails: file does not exist, path is a directory, or the process lacks read permission.","commonSituations":"Typo in the connection profile path passed via -f/--config or FABRIC_CFG_PATH settings; running the peer CLI from a different working directory than expected; file permissions changed after container mount; profile deleted or never generated.","solutions":["Verify the file exists at the given path: ls -l <path>","Check read permissions on the file and traverse permissions on its directories","Run the command from the directory containing the profile or pass an absolute path","Confirm the correct profile file name is passed (e.g. connection-org1.yaml, not connection-org1.json)"],"exampleFix":"// before\nconfig, err := common.GetConfig(\"connection-org1.yaml\")\n// after\nconfig, err := common.GetConfig(\"/absolute/path/to/connection-org1.yaml\")\nif err != nil {\n    log.Fatalf(\"check connection profile path: %v\", err)\n}","handlingStrategy":"validation","validationCode":"func profileExists(path string) error {\n    if path == \"\" {\n        return errors.New(\"connection profile path is empty\")\n    }\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"connection profile not accessible: %w\", err)\n    }\n    if info.IsDir() {\n        return fmt.Errorf(\"%s is a directory, not a file\", path)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"config, err := common.GetConfig(profilePath)\nif err != nil {\n    if strings.Contains(err.Error(), \"error reading connection profile\") {\n        log.Fatalf(\"cannot read connection profile %q: %v\", profilePath, err)\n    }\n    return err\n}","preventionTips":["Always pass absolute paths to connection profiles","Add a startup check that the profile file exists and is readable","Mount profiles read-only into containers and verify paths after mounting"],"tags":["fabric","config","file-io"],"backgroundTag":"config-file-not-found","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}