{"record":{"id":"c6b2bd710b383b9a","repo":"hyperledger/fabric","slug":"error-unmarshalling-yaml-s","errorCode":null,"errorMessage":"Error Unmarshalling YAML: %s","messagePattern":"Error Unmarshalling YAML: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cryptogen/main.go","lineNumber":274,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"Error reading configuration: %s\", err)\n\t\t}\n\n\t\tconfigData = string(data)\n\t} else if *extConfigFile != nil {\n\t\tdata, err := io.ReadAll(*extConfigFile)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error reading configuration: %s\", err)\n\t\t}\n\n\t\tconfigData = string(data)\n\t} else {\n\t\tconfigData = defaultConfig\n\t}\n\n\tconfig := &Config{}\n\terr := yaml.Unmarshal([]byte(configData), &config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error Unmarshalling YAML: %s\", err)\n\t}\n\n\treturn config, nil\n}\n\nfunc extend() {\n\tconfig, err := getConfig()\n\tif err != nil {\n\t\tfmt.Printf(\"Error reading config: %s\", err)\n\t\tos.Exit(-1)\n\t}\n\n\tfor _, orgSpec := range config.PeerOrgs {\n\t\terr = renderOrgSpec(&orgSpec, \"peer\")\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Error processing peer configuration: %s\", err)\n\t\t\tos.Exit(-1)\n\t\t}","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/cryptogen/main.go#L256-L292","documentation":"getConfig parses the read YAML data into the Config struct with yaml.Unmarshal. If the content is not valid YAML or does not match the expected schema, this error wraps the YAML parse error. It is a configuration content problem, not an I/O problem.","triggerScenarios":"Running cryptogen generate/extend with a --config file containing malformed YAML (bad indentation, tabs, duplicate keys) or unknown/wrongly-typed fields.","commonSituations":"Hand-edited crypto-config.yaml with tab characters instead of spaces; missing OrdererOrgs/PeerOrgs sections; wrong types (e.g. Counts as string); YAML copied from docs with smart quotes; Windows line endings.","solutions":["Read the wrapped YAML error line/column and fix that spot in the file.","Validate the YAML first (yamllint or a YAML parser) before running cryptogen.","Replace tabs with spaces and ensure consistent indentation.","Compare against a known-good crypto-config.yaml from the fabric-samples repo."],"exampleFix":"// before (tabs break YAML)\nPeerOrgs:\n\t- Name: Org1\n// after\nPeerOrgs:\n  - Name: Org1","handlingStrategy":"validation","validationCode":"// validate YAML before invoking cryptogen\nimport \"gopkg.in/yaml.v3\"\nvar probe map[string]any\nif err := yaml.Unmarshal([]byte(configData), &probe); err != nil {\n    log.Fatalf(\"invalid YAML: %v\", err)\n}\nif _, ok := probe[\"PeerOrgs\"]; !ok { log.Fatal(\"missing PeerOrgs section\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run yamllint on crypto-config.yaml before use","Use spaces, never tabs, in YAML","Start from a known-good sample config and edit minimally","Check the wrapped line/column in the error to locate the fault"],"tags":["yaml","cryptogen","configuration"],"backgroundTag":"yaml-parse-error","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"}