fablo icon indicating copy to clipboard operation
fablo copied to clipboard

Fablo fails with jq error when no fabric-shim dep is provided in package.json

Open dzikowski opened this issue 3 years ago • 2 comments

It shouldn't since, it may be a peer dependency or a dependency of a dependency

Current output:

jq: error (at /xxx/package.json:75): null (null) and string ("1.4.") cannot have their containment checked

dzikowski avatar Jun 14 '22 07:06 dzikowski

Hey @dzikowski is fablo still facing this issue? if yes can you guide me a bit reproduce this and if possible some more context will be helpful while addressing this issue.

Sanket-0510 avatar Apr 09 '24 20:04 Sanket-0510

Long story short we use jq to detect which version of fabric-shim the chaincode uses. Depending on the version of fabric-shim we are able to recommend node version to use:

    USES_OLD_FABRIC_SHIM="$(jq '.dependencies."fabric-shim" | contains("1.4.")' "$CHAINCODE_DIR_PATH/package.json")"
    if [ "$USES_OLD_FABRIC_SHIM" == "true" ]; then
      RECOMMENDED_NODE_VERSION="8.9"
    fi

This check is wrong because of two reasons:

  1. fabric-shim instead of a direct dependency might be a dependency of dependency. In this case it is missing in package.json and the check fails.
  2. Our code for recommending Node.js version does not cover newer Fabric releases that use Node 18, see: https://github.com/hyperledger/fabric-chaincode-node/blob/main/COMPATIBILITY.md

To address the first issue, we should probably check version in $CHAINCODE_DIR_PATH/node_modules/fabric-shim/package.json instead of $CHAINCODE_DIR_PATH/package.json.

To address the second issue, we should cover wider range of recommended versions, as in https://github.com/hyperledger/fabric-chaincode-node/blob/main/COMPATIBILITY.md

dzikowski avatar Apr 09 '24 21:04 dzikowski