{"record":{"id":"84dce33dcb6b46f0","repo":"hyperledger/fabric","slug":"instance-has-not-yet-been-built-cannot-wait","errorCode":null,"errorMessage":"instance has not yet been built, cannot wait","messagePattern":"instance has not yet been built, cannot wait","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/container.go","lineNumber":64,"sourceCode":"\tWait() (int, error)\n}\n\ntype UninitializedInstance struct{}\n\nfunc (UninitializedInstance) Start(peerConnection *ccintf.PeerConnection) error {\n\treturn errors.Errorf(\"instance has not yet been built, cannot be started\")\n}\n\nfunc (UninitializedInstance) ChaincodeServerInfo() (*ccintf.ChaincodeServerInfo, error) {\n\treturn nil, errors.Errorf(\"instance has not yet been built, cannot get chaincode server info\")\n}\n\nfunc (UninitializedInstance) Stop() error {\n\treturn errors.Errorf(\"instance has not yet been built, cannot be stopped\")\n}\n\nfunc (UninitializedInstance) Wait() (int, error) {\n\treturn 0, errors.Errorf(\"instance has not yet been built, cannot wait\")\n}\n\n//go:generate counterfeiter -o mock/package_provider.go --fake-name PackageProvider . PackageProvider\n\n// PackageProvider gets chaincode packages from the filesystem.\ntype PackageProvider interface {\n\tGetChaincodePackage(packageID string) (md *persistence.ChaincodePackageMetadata, mdBytes []byte, codeStream io.ReadCloser, err error)\n}\n\ntype Router struct {\n\tExternalBuilder ExternalBuilder\n\tDockerBuilder   DockerBuilder\n\tcontainers      map[string]Instance\n\tPackageProvider PackageProvider\n\tmutex           sync.Mutex\n}\n\nfunc (r *Router) getInstance(ccid string) Instance {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/container.go#L46-L82","documentation":"UninitializedInstance.Wait is the placeholder implementation: Wait blocks for a built container's exit code, and since no instance was ever built there is nothing to wait on. The call always returns this error.","triggerScenarios":"Calling Wait() on an Instance whose underlying type is UninitializedInstance — e.g. the peer's handler waits for chaincode termination for a chaincode whose build never produced a real instance.","commonSituations":"Chaincode launch failed silently earlier (no DockerBuilder, external builder produced nothing) and later lifecycle code waits on the instance exit; legacy docker path used while Docker is disabled.","solutions":["Fix the earlier build failure so a real instance is registered, then Wait will function.","Rebuild/redeploy the chaincode package to replace the placeholder instance.","Check peer logs for 'no DockerBuilder, cannot build' or external-builder errors preceding this, and fix that root cause."],"exampleFix":"// before\nexitCode, err := instance.Wait()\n\n// after: verify the instance was built before waiting\nif _, err := instance.ChaincodeServerInfo(); err != nil {\n\treturn errors.WithMessage(err, \"chaincode not built, cannot wait\")\n}\nexitCode, err := instance.Wait()","handlingStrategy":"try-catch","validationCode":"// only wait on instances that actually built\nif _, err := instance.ChaincodeServerInfo(); err != nil {\n\treturn errors.WithMessage(err, \"instance not built; skip Wait\")\n}","typeGuard":"func isWaitable(inst container.Instance) bool {\n\t_, err := inst.ChaincodeServerInfo()\n\treturn err == nil\n}","tryCatchPattern":"exitCode, err := instance.Wait()\nif err != nil {\n\tif strings.Contains(err.Error(), \"not yet been built\") {\n\t\treturn rebuildAndWait(ccid) // rebuild then wait\n\t}\n\treturn err\n}","preventionTips":["Diagnose the earlier build failure that left the placeholder registered","Ensure launch/stop/wait lifecycle order follows a successful Build","Align external builder package types with installed chaincode packages"],"tags":["chaincode","lifecycle","hyperledger-fabric","uninitialized"],"backgroundTag":"uninitialized-instance","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"}