{"record":{"id":"83b2b47e1b3fab2d","repo":"hyperledger/fabric","slug":"failed-to-marshal-chaincode-package-metadata-into","errorCode":null,"errorMessage":"failed to marshal chaincode package metadata into JSON","messagePattern":"failed to marshal chaincode package metadata into JSON","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/package.go","lineNumber":231,"sourceCode":"}\n\n// PackageMetadata holds the path and type for a chaincode package\ntype PackageMetadata struct {\n\tPath  string `json:\"path\"`\n\tType  string `json:\"type\"`\n\tLabel string `json:\"label\"`\n}\n\nfunc toJSON(path, ccType, label string) ([]byte, error) {\n\tmetadata := &PackageMetadata{\n\t\tPath:  path,\n\t\tType:  ccType,\n\t\tLabel: label,\n\t}\n\n\tmetadataBytes, err := json.Marshal(metadata)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to marshal chaincode package metadata into JSON\")\n\t}\n\n\treturn metadataBytes, nil\n}\n","sourceCodeStart":213,"sourceCodeEnd":236,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/package.go#L213-L236","documentation":"Wrapping error in toJSON: json.Marshal failed on the PackageMetadata struct (path/type/label) while assembling a chaincode package. This is highly unusual since the struct is plain strings; it indicates an environment/JSON package anomaly rather than user input, and the failure aborts packaging of the .tar.gz metadata file.","triggerScenarios":"Thrown at internal/peer/lifecycle/chaincode/package.go:231 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the specific marshal failure","Verify the path/type/label strings contain valid UTF-8 (invalid bytes can fail JSON encoding)","Retry the package lifecycle chaincode package command; if persistent, report as an environment bug"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}