{"record":{"id":"5d0aa6dc20de3a05","repo":"hyperledger/fabric","slug":"failed-to-inject-s-s","errorCode":null,"errorMessage":"Failed to inject \"%s\": %s","messagePattern":"Failed to inject \"(.+?)\": (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/platforms.go","lineNumber":128,"sourceCode":"\nfunc (r *Registry) StreamDockerBuild(ccType, path string, codePackage io.Reader, inputFiles map[string][]byte, tw *tar.Writer, client dcli.APIClient) error {\n\tvar err error\n\n\t// ----------------------------------------------------------------------------------------------------\n\t// Determine our platform driver from the spec\n\t// ----------------------------------------------------------------------------------------------------\n\tplatform, ok := r.Platforms[ccType]\n\tif !ok {\n\t\treturn fmt.Errorf(\"could not find platform of type: %s\", ccType)\n\t}\n\n\t// ----------------------------------------------------------------------------------------------------\n\t// First stream out our static inputFiles\n\t// ----------------------------------------------------------------------------------------------------\n\tfor name, data := range inputFiles {\n\t\terr = r.PackageWriter.Write(name, data, tw)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(`Failed to inject \"%s\": %s`, name, err)\n\t\t}\n\t}\n\n\tvar (\n\t\tgoVersion   string\n\t\tosVersion   string\n\t\tarchVersion string\n\t)\n\tif ccType == pb.ChaincodeSpec_GOLANG.String() {\n\t\tgoVersion, osVersion, archVersion, err = util.ParamsImage(client)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"get params docker image failed\")\n\t\t}\n\t}\n\n\tbuildOptions, err := platform.DockerBuildOptions(path, goVersion, osVersion, archVersion)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"platform failed to create docker build options\")","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/platforms.go#L110-L146","documentation":"StreamDockerBuild injects static input files (e.g. .dockercontext entries) into the tar writer via r.PackageWriter.Write. If that write fails, the build context is incomplete, so it aborts with 'Failed to inject <name>'. The wrapped underlying error indicates the actual write problem.","triggerScenarios":"GenerateDockerBuild -> StreamDockerBuild looping over inputFiles where PackageWriter.Write(name, data, tw) returns an error — tar write failures, closed/failed writer, or oversized/bad data for a given input file name.","commonSituations":"System resource limits (disk/memory) during docker build context streaming, corrupted writer state after a previous failed write, or customized inputFiles map containing problematic entries.","solutions":["Inspect the wrapped underlying error for the true write failure and fix it (disk space, memory, permissions).","Retry the chaincode build/install — transient stream failures often clear.","Reduce the size/number of static input files in customized builds.","If running a custom peer, verify the PackageWriter implementation and inputFiles construction."],"exampleFix":"// before (custom input with unreadable data)\ninputFiles[\"Dockerfile\"] = nil\n// after\ninputFiles[\"Dockerfile\"] = []byte(dockerfileContents)","handlingStrategy":"try-catch","validationCode":"// ensure all static input files have non-empty byte data before streaming\nfor (const [name, data] of Object.entries(inputFiles)) {\n  if (!Buffer.isBuffer(data) || data.length === 0) throw new Error(`bad input file: ${name}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  err = streamDockerBuild(ccType, inputFiles, ...)\n} catch (err) {\n  if (/Failed to inject/.test(err.message)) {\n    // fix the named input file / free resources, then retry the build\n  }\n  throw err\n}","preventionTips":["Verify static input files are valid before building","Watch disk/memory during docker build context streaming","Retry on transient write failures","In custom builds, test PackageWriter with all expected input entries"],"tags":["chaincode","docker","build","io"],"backgroundTag":"packaging-write-failed","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"}