Skip to content

Commit

Permalink
Improve an error message in InstallChaincode
Browse files Browse the repository at this point in the history
In case a 'chaincode already successfully installed' error occurs when
installing a chaincode, Fabric admins cannot to know the package ID.
In this case, if multiple chaincode packages with the same label are installed,
it is not possible to identify them later by using `queryinstalled`.

So, this patch adds the package ID to the error message in the case of
'chaincode already successfully installed'.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
  • Loading branch information
satota2 authored and denyeart committed Sep 28, 2021
1 parent 3a93662 commit cf341ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/chaincode/lifecycle/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func (ef *ExternalFunctions) InstallChaincode(chaincodeInstallPackage []byte) (*
// installed a chaincode with this package id
<-buildStatus.Done()
if buildStatus.Err() == nil {
return nil, errors.New("chaincode already successfully installed")
return nil, errors.Errorf("chaincode already successfully installed (package ID '%s')", packageID)
}
buildStatus = ef.BuildRegistry.ResetBuildStatus(packageID)
}
Expand Down
2 changes: 1 addition & 1 deletion core/chaincode/lifecycle/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ var _ = Describe("ExternalFunctions", func() {

It("does not attempt to rebuild it itself", func() {
_, err := ef.InstallChaincode([]byte("cc-package"))
Expect(err).To(MatchError("chaincode already successfully installed"))
Expect(err).To(MatchError("chaincode already successfully installed (package ID 'fake-hash')"))
Expect(fakeChaincodeBuilder.BuildCallCount()).To(Equal(0))
})
})
Expand Down

0 comments on commit cf341ee

Please sign in to comment.