{"record":{"id":"521f027c12b62bf7","repo":"hyperledger/fabric","slug":"builder-s-run-failed","errorCode":null,"errorMessage":"builder '%s' run failed","messagePattern":"builder '(.+?)' run failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/externalbuilder/instance.go","lineNumber":188,"sourceCode":"\tcase <-done:\n\t\treturn nil\n\t}\n\n\tselect {\n\tcase <-time.After(5 * time.Second):\n\t\treturn errors.Errorf(\"failed to stop instance '%s'\", i.PackageID)\n\tcase <-done:\n\t\treturn nil\n\t}\n}\n\nfunc (i *Instance) Wait() (int, error) {\n\tif i.Session == nil {\n\t\treturn -1, errors.Errorf(\"instance was not successfully started\")\n\t}\n\n\terr := i.Session.Wait()\n\terr = errors.Wrapf(err, \"builder '%s' run failed\", i.Builder.Name)\n\tif exitErr, ok := errors.Cause(err).(*exec.ExitError); ok {\n\t\treturn exitErr.ExitCode(), err\n\t}\n\treturn 0, err\n}\n","sourceCodeStart":170,"sourceCodeEnd":194,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/externalbuilder/instance.go#L170-L194","documentation":"Wait wraps any error from Session.Wait() (the underlying exec session wait) with the message \"builder '<name>' run failed\". This means the builder process ran but terminated abnormally — non-zero exit, signal death, or exec wait failure.","triggerScenarios":"The external builder binary exits with a non-zero exit code, is killed by a signal, or exec's wait fails while Instance.Wait() is collecting it.","commonSituations":"Builder script fails to compile chaincode (bad Go code, missing deps in vendored modules); builder image/binary missing dependencies; OOM-killer terminating the build; misconfigured builder producing exit code 1.","solutions":["Read the wrapped exec.ExitError's ExitCode() and the builder's stderr/stdout logs to find the underlying build failure.","Run the builder command manually with the same env/args to reproduce and debug the failure.","Fix the chaincode or builder script (missing packages, compile errors, bad toolchain versions).","Check container/host memory limits if the builder is being killed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if exitErr, ok := err.(*exec.ExitError); ok {\n    logger.Errorf(\"builder failed with exit code %d\", exitErr.ExitCode())\n}","typeGuard":"func isExitError(err error) (*exec.ExitError, bool) {\n    var ee *exec.ExitError\n    if errors.As(err, &ee) {\n        return ee, true\n    }\n    return nil, false\n}","tryCatchPattern":"code, err := inst.Wait()\nif err != nil {\n    var exitErr *exec.ExitError\n    if errors.As(err, &exitErr) {\n        return fmt.Errorf(\"builder exited %d: %w\", exitErr.ExitCode(), err)\n    }\n    return err\n}","preventionTips":["Capture and keep builder stdout/stderr for diagnosis.","Validate chaincode compiles in CI with the same builder.","Pin builder toolchain versions and dependency sources.","Set memory/CPU limits high enough for the build step."],"tags":["build","process-exit","chaincode"],"backgroundTag":"process-exited-nonzero","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"}