anyeone
anyeone

Reputation: 251

Error running query from hyperledger composer Queries tutorial against couchdb Fabric runtime

I am trying to connect the dots between Composer and Fabric to build a proof of concept application that supports multiple orgs. So, I am using the Composer tutorials to build the business network and then the "Deploying to a multi-organization business network" tutorial (which references the Fabric "Build your first network" tutorial, but tells you to use a different git repo than the BYFN tutorial, which I did).

I was able to use the Developer tutorial from Composer to build the simple trade business network, and then copy the archive to the folder where I built out the multi-org business network with Fabric (which requires couchdb, which I'd want to use anyway in order to be able to do more complex querying), start it all up and then use the explorer REST API to create participants, assets, and trade transactions. This all worked fine.

Then, I moved onto the Composer Queries tutorial to add the queries.qry, generate a new archive, copied & updated the fabric install of the archive, stopped & updated & restarted the REST API server. I can see the queries in the REST API now so I know it has picked up the new code. However, regardless of which of the queries I try to run through the REST API explorer, they all return the same error:

  {
  "error": {
    "statusCode": 500,
    "name": "Error",
    "message": "Error trying to query business network. Error: chaincode error (status: 500, message: Error: Couch DB Error:invalid_operator,  Status Code:400,  Reason:Invalid operator: $class)",
    "stack": "Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: Couch DB Error:invalid_operator,  Status Code:400,  Reason:Invalid operator: $class)\n    at channel.queryByChaincode.then.catch (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:809:34)\n    at <anonymous>"
  }
}

The simplest of the queries from the tutorial is a simple get all with no arguments, so the problem can't be what I'm passing in (as there is literally nothing to pass in). The problem has to be something systemic.

Example: the get all commodities query

query selectCommodities {
  description: "Select all commodities"
  statement:
      SELECT org.acme.biznet.Commodity
}

The error message says it doesn't like $class in the response.

The response from the GET all commodities endpoint (which doesn't use the query) is:

[
  {
    "$class": "org.acme.biznet.Commodity",
    "tradingSymbol": "KPX",
    "description": "KnitPicks",
    "mainExchange": "SP",
    "quantity": 50,
    "owner": "resource:org.acme.biznet.Trader#4567"
  },
  {
    "$class": "org.acme.biznet.Commodity",
    "tradingSymbol": "KPX2",
    "description": "KnitPicks",
    "mainExchange": "SP",
    "quantity": 120,
    "owner": "resource:org.acme.biznet.Trader#4567"
  }
]

and the API doc for the selectCommodities query sample response is of the same format:

[
  {
    "$class": "org.acme.biznet.Commodity",
    "tradingSymbol": "string",
    "description": "string",
    "mainExchange": "string",
    "quantity": 0,
    "owner": {}
  }
]

so I am not sure what is wrong, but it seems like it would have to be either a problem with the query itself not being compatible with CouchDB, or a problem in the translation layer from the query in Composer to the low level Fabric API? The latter theory is supported by the 500 being returned by the Composer API layer having a nested 400 error, implying that something that the Composer layer through hlfconnection is passing is invalid.

Any help is greatly appreciated! I can't imagine I'm the first to run across this but I haven't found anything online that's directly related. Thanks in advance!

Composer version 0.16.6

Docker PS:

f844a2957bd5 dev-peer0.org2.example.com-tutorial-network-0.16.6-95a0f8a4fe6ff659a5943abc80b26a1134e77b74942eef102fa92c8480b680eb "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer0.org2.example.com-tutorial-network-0.16.6 556c9f3841ce dev-peer0.org1.example.com-tutorial-network-0.16.6-e4f751b9b8b3a307f6bf25ea97ccf3625bd75730a1dcb3f989a9a34bbb73f536 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer0.org1.example.com-tutorial-network-0.16.6 831ca5b9a839 dev-peer1.org2.example.com-tutorial-network-0.16.6-a184efa69bdcbcb2e6ec3764e01d56f0c574ca0ad09d4656269d3b7aefbc44b8 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer1.org2.example.com-tutorial-network-0.16.6 6faf5b875df9 dev-peer1.org1.example.com-tutorial-network-0.16.6-44b9f2a6ea1ed75f106aa0b5fc8387c95cbde9eee551df9fb36d16709f2db981 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer1.org1.example.com-tutorial-network-0.16.6 afbcbe9292fd dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer1.org2.example.com-mycc-1.0 8444f922486d dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer0.org1.example.com-mycc-1.0 753588bacb47 dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer0.org2.example.com-mycc-1.0 662b61c00673 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com 80a37822a0d6 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com 2878eacafb29 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com e8f3259dca2a hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com a79c29e762cd hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1 34271122957a hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp couchdb3 8b88227ea7a7 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 26 hours ago Up 26 hours 0.0.0.0:7054->7054/tcp ca_peerOrg1 a75fa6328b02 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 26 hours ago Up 26 hours 0.0.0.0:8054->7054/tcp ca_peerOrg2 4e21c3c8fa16 hyperledger/fabric-orderer "orderer" 26 hours ago Up 26 hours 0.0.0.0:7050->7050/tcp orderer.example.com 2881999a4c7b hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb2 8a77a5e86a3a hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0

Upvotes: 1

Views: 474

Answers (1)

Paul O&#39;Mahony
Paul O&#39;Mahony

Reputation: 6740

This is probably due to a match of Composer version (16.x) to versions of Fabric (1.1). Composer 0.16.x ONLY works with Fabric v1.0.x (you can check from your logs / docker images what you installed). The release notes detail which versions of composer will work with which versions of fabric. eg https://github.com/hyperledger/composer/releases

Composer v0.18.2 and above is compatible with Fabric 1.1 GA only
Composer v0.18.0 -> v0.18.1 : compatible with the Fabric 1.1 RC1 driver only
Composer v0.17.3 -> v0.17.6 (old) are compatible with Fabric 1.1 alpha driver only

Composer v0.16.x -> compatible with Fabric v1.0.x only

Upvotes: 1

Related Questions