{"record":{"id":"c195de8b94e03f3e","repo":"hyperledger/fabric","slug":"nil-data-c195de","errorCode":null,"errorMessage":"nil data","messagePattern":"nil data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/common/ccprovider/sigcdspackage.go","lineNumber":298,"sourceCode":"func (ccpack *SignedCDSPackage) PutChaincodeToFS() error {\n\tif ccpack.buf == nil {\n\t\treturn errors.New(\"uninitialized package\")\n\t}\n\n\tif ccpack.id == nil {\n\t\treturn errors.New(\"id cannot be nil if buf is not nil\")\n\t}\n\n\tif ccpack.sDepSpec == nil || ccpack.depSpec == nil {\n\t\treturn errors.New(\"depspec cannot be nil if buf is not nil\")\n\t}\n\n\tif ccpack.env == nil {\n\t\treturn errors.New(\"env cannot be nil if buf and depspec are not nil\")\n\t}\n\n\tif ccpack.data == nil {\n\t\treturn errors.New(\"nil data\")\n\t}\n\n\tif ccpack.datab == nil {\n\t\treturn errors.New(\"nil data bytes\")\n\t}\n\n\tccname := ccpack.depSpec.ChaincodeSpec.ChaincodeId.Name\n\tccversion := ccpack.depSpec.ChaincodeSpec.ChaincodeId.Version\n\n\t// return error if chaincode exists\n\tpath := fmt.Sprintf(\"%s/%s.%s\", chaincodeInstallPath, ccname, ccversion)\n\tif _, err := os.Stat(path); err == nil {\n\t\treturn fmt.Errorf(\"chaincode %s exists\", path)\n\t}\n\n\tif err := os.WriteFile(path, ccpack.buf, 0o644); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/common/ccprovider/sigcdspackage.go#L280-L316","documentation":"During PutChaincodeToFS, after env and depSpec validation pass, the package's data (the unpacked bytes, typically the chaincode install payload) is checked. This error means the package has metadata fields populated but the actual data payload is nil, so it cannot be persisted. The library throws it to prevent writing an empty/invalid chaincode package to disk.","triggerScenarios":"PutChaincodeToFS is called on a SignedCDSPackage whose data field was never populated — e.g., processSignedCDS failed to extract the payload from the buf bytes, or a caller constructed the package struct manually without data.","commonSituations":"Truncated or corrupt chaincode install packages on the file system, packages produced by mismatched fabric versions, custom install tooling that sets depSpec but forgets the raw data payload.","solutions":["Populate ccpack.data with the unmarshaled package payload before calling PutChaincodeToFS","Regenerate the chaincode package (peer lifecycle chaincode package) and retry the install","Check for disk corruption or interrupted previous install; delete the stale package file and reinstall"],"exampleFix":"// before\npack.data = nil\nccprovider.PutChaincodeToFS(pack) // errors: nil data\n\n// after\npack.data, err = ccpack.GetInstantiationPolicy(...) // or set the extracted payload\nif err != nil { return err }\nccprovider.PutChaincodeToFS(pack)","handlingStrategy":"validation","validationCode":"if pack != nil && pack.Buf != nil && (pack.Data == nil) {\n  return errors.New(\"package has buf but nil data; rebuild package\")\n}","typeGuard":"func hasPackageData(p *ccprovider.SignedCDSPackage) bool {\n  return p != nil && p.Data != nil\n}","tryCatchPattern":"err := ccprovider.PutChaincodeToFS(pack)\nif err != nil {\n  if strings.Contains(err.Error(), \"nil data\") {\n    return fmt.Errorf(\"package payload missing; repackage chaincode: %w\", err)\n  }\n  return err\n}","preventionTips":["Repackage chaincode with peer lifecycle tooling rather than reusing old package bytes","Check package file integrity (size, hash) before install","Never edit packaged install files by hand"],"tags":["chaincode-install","nil-check","fabric"],"backgroundTag":"nil-required-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"}