balena-io / open-balena-api

The core API of openBalena
https://balena.io/open
GNU Affero General Public License v3.0
59 stars 29 forks source link

"contract" is not an object/array: string while deploying on openbalena #1427

Closed xouillet closed 10 months ago

xouillet commented 1 year ago

Hi,

I'm trying to switch from balena cloud server to a self-hosted open-balena instance.

When deploying a release with a balena.yml file, I get the error

[Info]    Creating release...
[Error]   Deploy failed
"contract" is not an object/array: string

BadRequestError: "contract" is not an object/array: string
    at wrapResponseError (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@balena/compose/dist/release/models.js:49:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.create (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@balena/compose/dist/release/api.js:25:21)
    at async createRelease (/home/alexandre/src/robocc/balena/balena-cli/build/utils/compose.js:47:40)
    at async runSpinner (/home/alexandre/src/robocc/balena/balena-cli/build/utils/compose_ts.js:817:16)
    at async deployProject (/home/alexandre/src/robocc/balena/balena-cli/build/utils/compose_ts.js:767:22)
    at async DeployCmd.deployProject (/home/alexandre/src/robocc/balena/balena-cli/build/commands/deploy.js:151:27)
    at async DeployCmd.run (/home/alexandre/src/robocc/balena/balena-cli/build/commands/deploy.js:50:25)
    at async DeployCmd._run (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@oclif/config/lib/config.js:175:24)
    at async CustomMain.run (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@oclif/command/lib/main.js:28:9)
    at async CustomMain._run (/home/alexandre/src/robocc/balena/balena-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async /home/alexandre/src/robocc/balena/balena-cli/build/app.js:76:13
    at async Promise.all (index 2)
    at async oclifRun (/home/alexandre/src/robocc/balena/balena-cli/build/app.js:94:5)
    at async Object.run (/home/alexandre/src/robocc/balena/balena-cli/build/app.js:107:9)

The exact same deployment works without issue on cloud balena.

If I delete the balena.yml file, the release is correctly created on openbalena (but without the semver and other information from balena.yml obviously...).

jianhu commented 1 year ago

second on this one.

when I am looking at it, it's cli that sends stringified contract object, while api-server only accepts object which leads to one rejected request. so I guess it's the cli part needs to be updated.

xouillet commented 1 year ago

Yes, modifying the balena-cli source make it works, but it means that there is a difference between cloud api and openbalena api...

dcaputo-harmoni commented 11 months ago

I've encountered this error as well, and think it can easily be handled by open-balena-api by checking for contracts provided as a string, and parsing the object from it. I'm submitting a PR to this effect.

dcaputo-harmoni commented 11 months ago

The PR can be found here: https://github.com/balena-io/open-balena-api/pull/1468

Page- commented 10 months ago

This should be fixed as of v14.17.0