{"record":{"id":"0a91d09946c7800a","repo":"hyperledger/fabric","slug":"instance-has-not-yet-been-built-cannot-get-chainc","errorCode":null,"errorMessage":"instance has not yet been built, cannot get chaincode server info","messagePattern":"instance has not yet been built, cannot get chaincode server info","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/container.go","lineNumber":56,"sourceCode":"\n// Instance represents a built chaincode instance, because of the docker legacy, calling this a\n// built 'container' would be very misleading, and going forward with the external launcher\n// 'image' also seemed inappropriate.  So, the vague 'Instance' is used here.\ntype Instance interface {\n\tStart(peerConnection *ccintf.PeerConnection) error\n\tChaincodeServerInfo() (*ccintf.ChaincodeServerInfo, error)\n\tStop() error\n\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 {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/container.go#L38-L74","documentation":"UninitializedInstance is the placeholder Instance stored in the BuildRegistry when a chaincode package exists but no build has actually produced a runnable instance. All methods on it fail because the container lifecycle cannot be driven without a real built instance. ChaincodeServerInfo is called by the peer to learn where a chaincode server is listening; since nothing was built, there is no server info to return.","triggerScenarios":"Calling ChaincodeServerInfo() on an Instance whose registered concrete type is UninitializedInstance, i.e. the chaincode was registered as 'built' via a non-Docker/external build path that produced no instance, or the build step was skipped/failed and the placeholder was still handed to the launcher.","commonSituations":"External builder configured but produced no bld/folder or no instance; DockerBuilder disabled (core.yaml chaincode.externalBuilders / docker build path removed) while using the legacy docker chaincode path; a build race where the launcher queries before the real build completed.","solutions":["Fix the chaincode build so a real Instance is produced (ensure the external builder emits a valid build output, or re-enable the DockerBuilder).","Rebuild/redeploy the chaincode package (lifecycle install + approve + commit) so the registry holds a real instance instead of the placeholder.","Check peer logs for the earlier build failure that left the UninitializedInstance registered, and correct the underlying build error.","Verify peer configuration: if using external builders exclusively, ensure the builder declares the required runtime and the package type matches one of the configured builders."],"exampleFix":"// before: launching against a placeholder instance\ninfo, err := instance.ChaincodeServerInfo() // fails\n\n// after: only use the instance after a successful build\nif err := reg.Build(ccid); err != nil {\n\treturn errors.WithMessage(err, \"chaincode build failed\")\n}\ninfo, err := instance.ChaincodeServerInfo()","handlingStrategy":"validation","validationCode":"// ensure the chaincode built before querying server info\nif err := registry.Build(ccid); err != nil {\n\treturn errors.WithMessage(err, \"chaincode not built\")\n}","typeGuard":"func isBuilt(inst container.Instance) bool {\n\t_, err := inst.ChaincodeServerInfo()\n\treturn !strings.Contains(fmt.Sprint(err), \"not yet been built\")\n}","tryCatchPattern":"info, err := instance.ChaincodeServerInfo()\nif err != nil {\n\tif strings.Contains(err.Error(), \"not yet been built\") {\n\t\t// rebuild first, then retry\n\t\treturn rebuildChaincode(ccid)\n\t}\n\treturn err\n}","preventionTips":["Always call Build and check its error before any launcher interaction with the instance","Ensure the external builder output includes a valid connection.json so a real instance is registered","Enable the DockerBuilder fallback if you install legacy-type packages","Watch peer logs for build failures before launch attempts"],"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"}