{"record":{"id":"e412962aeb1aa72e","repo":"hyperledger/fabric","slug":"s-is-mandatory-and-cannot-be-empty","errorCode":null,"errorMessage":"%s is mandatory and cannot be empty","messagePattern":"(.+?) is mandatory and cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/common/config.go","lineNumber":64,"sourceCode":"\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to marshal config\")\n\t}\n\tif err := os.WriteFile(file, b, 0o600); err != nil {\n\t\treturn errors.Errorf(\"failed writing file %s: %v\", file, err)\n\t}\n\treturn nil\n}\n\nfunc validateConfig(conf Config) error {\n\tnonEmptyElems := map[string]string{\n\t\t\"MSPID\":        conf.SignerConfig.MSPID,\n\t\t\"IdentityPath\": conf.SignerConfig.IdentityPath,\n\t\t\"KeyPath\":      conf.SignerConfig.KeyPath,\n\t}\n\n\tfor key, value := range nonEmptyElems {\n\t\tif value == \"\" {\n\t\t\treturn errors.Errorf(\"%s is mandatory and cannot be empty\", key)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":46,"sourceCodeEnd":70,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/common/config.go#L46-L70","documentation":"validateConfig enforces that mandatory config fields (ConfigPath-like entries: IdentityPath and KeyPath under SignerConfig, plus other nonEmptyElems) are non-empty strings. This error is returned by validateConfig, which both ConfigFromFile and ToFile invoke, so any load or persist of an incomplete config fails with the offending key name.","triggerScenarios":"Loading a config file via ConfigFromFile whose YAML omits signer.identity or signer.key, or calling ToFile on a programmatically built Config where SignerConfig.IdentityPath or SignerConfig.KeyPath is the empty string.","commonSituations":"Hand-edited config YAML missing the identity/key entries; environment-specific config generation that left fields blank; renamed config keys after a Fabric version upgrade; partial config templates.","solutions":["Set SignerConfig.IdentityPath and SignerConfig.KeyPath in the config to valid absolute paths of the enrollment cert and private key","Re-check the YAML key names against the Config struct fields (identity/key under signer)","Run validateConfig or ConfigFromFile locally to identify which key is empty from the error message","Regenerate the config from a known-good template"],"exampleFix":"// before (config.yaml)\nsigner:\n  key: /path/to/key.pem\n// after\nsigner:\n  identity: /path/to/cert.pem\n  key: /path/to/key.pem","handlingStrategy":"validation","validationCode":"conf, _ := common.ConfigFromFile(path)\nif conf.SignerConfig.IdentityPath == \"\" || conf.SignerConfig.KeyPath == \"\" {\n    return fmt.Errorf(\"signer identity/key must be set in %s\", path)\n}","typeGuard":null,"tryCatchPattern":"conf, err := common.ConfigFromFile(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"mandatory and cannot be empty\") {\n        log.Fatalf(\"incomplete config %s: %v\", path, err)\n    }\n    return err\n}","preventionTips":["Keep a complete config template and diff against it","Never hand-edit YAML without running the loader afterward","Pin key names (identity, key) to the struct fields in use","Validate config in CI before deployments"],"tags":["config","validation","fabric"],"backgroundTag":"missing-required-config-field","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"}