I’m writing a script that meant to create a new canton ledger on remote hub.daml.com cloud.
Following commands in bold passes successfully while the last one fails (“damlhub -j workspace install”):
damlhub token $accountToken damlhub workspace damlhub ledger create $projectId $ledgerName curl -s https://api.hub.daml.com/api/ledger/${LEDGER_ID}/healthz (verifying that the ledger is up via REST) damlhub ledger party $ledgerId $partyName damlhub -j workspace upload $darFullPath
damlhub -j workspace install $darName $ledgerId
The error thrown in CLI is:
damlhub -j workspace install models-0.0.1.dar kui8ilu2ijax3496
2022-12-01 19:26:31,913 ERROR [api] [ERROR] A non-JSON response was returned
Message: `something went wrong`
Status: 500
Unexpected error: SyntaxError: Unexpected token s in JSON at position 0
at JSON.parse (<anonymous>)
at /usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:300:52
at step (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:48:23)
at Object.next (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:29:53)
at fulfilled (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:20:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I’m struggling to understand what i’m missing here.
From first glance at damlhub-cli home page i saw that damlhub install command receives other arguments from what i sent:
damlhub workspace install {file_name} {ledger_id}
# Then retrieve the `artifact_hash` field from the JSON that returns
damlhub deployDar {ledger_id} {artifact_hash}
If the file remains the same, the artifact_hash will not change for future ledgers.
2022-12-01 20:39:55,347 ERROR [api] [ERROR] A non-JSON response was returned
Message: `404: Not Found`
Status: 404
Unexpected error: SyntaxError: Unexpected token : in JSON at position 3
at JSON.parse (<anonymous>)
at /usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:300:52
at step (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:48:23)
at Object.next (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:29:53)
at fulfilled (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:20:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Same phenomena. JSON Exception upon damlhub install command.
Triggering the command from within the DAR directory hasn’t made an improvment.
Should i maybe re-create the dar? What is the source of the Exception? Is it the remote ledger or the damlhub client itself?
Output again:
2022-12-02 07:46:53,917 ERROR [api] [ERROR] A non-JSON response was returned
Message: `something went wrong`
Status: 500
Unexpected error: SyntaxError: Unexpected token s in JSON at position 0
at JSON.parse (<anonymous>)
at /usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:300:52
at step (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:48:23)
at Object.next (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:29:53)
at fulfilled (/usr/local/lib/node_modules/damlhub-cli/lib/src/dabl/apiRequest.js:20:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)