{"record":{"id":"1ec022badf3fa44f","repo":"hyperledger/fabric","slug":"filename-cannot-be-empty","errorCode":null,"errorMessage":"filename cannot be empty","messagePattern":"filename cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/common/networkconfig.go","lineNumber":160,"sourceCode":"\t// Certfiles root certificates for TLS validation (Comma separated path list)\n\tPath string `yaml:\"path\"`\n\n\t// Client TLS information\n\tClient TLSKeyPair `yaml:\"client\"`\n}\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":142,"sourceCodeEnd":177,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/common/networkconfig.go#L142-L177","documentation":"GetConfig loads a connection profile (network configuration) from a file path; the function requires a non-empty filename. An empty string would attempt a pointless (and failing) file read, so it is rejected immediately with this sentinel error.","triggerScenarios":"Calling common.GetConfig(\"\") — e.g. the --connectionProfile flag or path variable was never set, an env var like the connection-profile path is empty/unset.","commonSituations":"Forgetting --connectionProfile on peer CLI commands, an empty configPath field in a wrapper script, env var (e.g. path to the profile YAML) not exported.","solutions":["Pass the path to a valid connection profile YAML/JSON file","Check the env var or flag feeding the fileName argument is set and non-empty","Verify the calling wrapper/CLI parsed the flag correctly"],"exampleFix":"// before\nprofilePath := os.Getenv(\"CONNECTION_PROFILE\") // empty!\nnc, err := common.GetConfig(profilePath)\n// after\nprofilePath := os.Getenv(\"CONNECTION_PROFILE\")\nif profilePath == \"\" { log.Fatal(\"CONNECTION_PROFILE must point to a connection profile file\") }\nnc, err := common.GetConfig(profilePath)","handlingStrategy":"validation","validationCode":"if profilePath == \"\" {\n    return errors.New(\"connection profile path is required\")\n}\nif _, err := os.Stat(profilePath); err != nil {\n    return fmt.Errorf(\"connection profile not found: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"nc, err := common.GetConfig(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"filename cannot be empty\") {\n        return errors.New(\"--connectionProfile flag or its env var was not set\")\n    }\n    return err\n}","preventionTips":["Always pass --connectionProfile explicitly on CLI calls","Fail fast in wrapper scripts when the profile path env var is empty","os.Stat the profile path before invoking GetConfig"],"tags":["fabric","connection-profile","validation","missing-argument"],"backgroundTag":"missing-file-path","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"}