balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
452 stars 138 forks source link

[openBalena] $ balena device generates an Internal Server Error #1970

Closed jimmyw closed 3 years ago

jimmyw commented 4 years ago

Expected Behavior

Expecting to get device data

Actual Behavior

$ balena device 99cd956 --debug
[debug] new argv=[/usr/local/Cellar/node/14.3.0/bin/node,/Users/jimmy/.npm-packages/bin/balena,device,99cd956] length=4
{
  statusCode: 500,
  duration: 357,
  apiKey: undefined,
  baseUrl: 'https://api.openbalena.wennlund.nu',
  sendToken: true,
  url: "https://api.openbalena.wennlund.nu/v5/device?$filter=startswith(uuid,'99cd956')&$select=device_name,id,device_type,overall_status,is_online,ip_address,mac_address,last_connectivity_event,uuid,is_on__commit,supervisor_version,is_web_accessible,note,os_version&$expand=belongs_to__application($select=app_name)",
  body: undefined,
  method: 'GET',
  timeout: 59000
}
BalenaRequestError: Request error: Internal Server Error

BalenaRequestError: Request error: Internal Server Error
    at /Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-request/build/request.js:189:17
From previous event:
    at /Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-request/build/request.js:181:62
From previous event:
    at Object.exports.send (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-request/build/request.js:180:8)
    at /Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-pine/es2018/index.js:20:22
    at processImmediate (internal/timers.js:456:21)
From previous event:
    at BalenaPine._request (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-pine/es2018/index.js:12:34)
    at BalenaPine.request (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/pinejs-client-core/es2018/index.js:952:29)
    at BalenaPine.get (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/pinejs-client-core/es2018/index.js:701:21)
    at /Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-sdk/build/models/device.js:355:26
From previous event:
    at Object.get (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-sdk/build/models/device.js:336:31)
    at Object.get (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/balena-sdk/build/util/callbacks.js:19:27)
    at DeviceCmd.run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/build/actions-oclif/device/index.js:13:55)
    at DeviceCmd._run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/@oclif/command/lib/command.js:44:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at runNextTicks (internal/process/task_queues.js:66:3)
    at processImmediate (internal/timers.js:429:9)
    at process.topLevelDomainCallback (domain.js:137:15)
    at async Config.runCommand (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/@oclif/config/lib/config.js:160:9)
    at async CustomMain.run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/@oclif/command/lib/main.js:21:9)
    at async CustomMain._run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/node_modules/@oclif/command/lib/command.js:44:20)
    at async Promise.all (index 1)
    at async Object.run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/build/app-oclif.js:31:9)
    at async routeCliFramework (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/build/preparser.js:44:9)
    at async Object.run (/Users/jimmy/.npm-packages/lib/node_modules/balena-cli/build/app.js:15:5)

Server side:

Jul 31 16:15:17 5d03591f8467 api[860]: Parsing PATCH /resin/service_instance(44)
Jul 31 16:15:17 5d03591f8467 api[860]: Running PATCH /resin/service_instance(44)
Jul 31 16:15:17 5d03591f8467 api[860]: UPDATE "service instance"
Jul 31 16:15:17 5d03591f8467 api[860]: SET "last heartbeat" = $1
Jul 31 16:15:17 5d03591f8467 api[860]: WHERE "service instance"."id" = $2 [ 2020-07-31T16:15:17.601Z, 44 ]
Jul 31 16:15:20 5d03591f8467 api[860]: Parsing GET /resin/user(2)?$select=actor,jwt_secret
Jul 31 16:15:20 5d03591f8467 api[860]: Running GET /resin/user(2)?$select=actor,jwt_secret
Jul 31 16:15:20 5d03591f8467 api[860]: SELECT "user"."actor", "user"."jwt secret" AS "jwt_secret"
Jul 31 16:15:20 5d03591f8467 api[860]: FROM "user"
Jul 31 16:15:20 5d03591f8467 api[860]: WHERE "user"."id" = $1 [ 2 ]
Jul 31 16:15:20 5d03591f8467 api[860]: Parsing GET /Auth/permission?$select=name&$filter=(is_of__user/any(uhp:(uhp/user eq @userId) and ((uhp/expiry_date eq null) or (uhp/expiry_date gt now())))) or (is_of__role/any(rhp:rhp/role/any(r:r/is_of__user/any(uhr:(uhr/user eq @userId) and ((uhr/expiry_date eq null) or (uhr/expiry_date gt now()))))))&$orderby=name asc&@userId=2
Jul 31 16:15:20 5d03591f8467 api[860]: Running GET /Auth/permission?$select=name&$filter=(is_of__user/any(uhp:(uhp/user eq @userId) and ((uhp/expiry_date eq null) or (uhp/expiry_date gt now())))) or (is_of__role/any(rhp:rhp/role/any(r:r/is_of__user/any(uhr:(uhr/user eq @userId) and ((uhr/expiry_date eq null) or (uhr/expiry_date gt now()))))))&$orderby=name asc&@userId=2
Jul 31 16:15:20 5d03591f8467 api[860]: SELECT "permission"."name"
Jul 31 16:15:20 5d03591f8467 api[860]: FROM "permission"
Jul 31 16:15:20 5d03591f8467 api[860]: WHERE (EXISTS (
Jul 31 16:15:20 5d03591f8467 api[860]:         SELECT 1
Jul 31 16:15:20 5d03591f8467 api[860]:         FROM "user-has-permission" AS "permission.user-has-permission"
Jul 31 16:15:20 5d03591f8467 api[860]:         WHERE "permission"."id" = "permission.user-has-permission"."permission"
Jul 31 16:15:20 5d03591f8467 api[860]:         AND "permission.user-has-permission"."user" = $1
Jul 31 16:15:20 5d03591f8467 api[860]:         AND ("permission.user-has-permission"."expiry date" IS NULL
Jul 31 16:15:20 5d03591f8467 api[860]:         OR "permission.user-has-permission"."expiry date" > CURRENT_TIMESTAMP)
Jul 31 16:15:20 5d03591f8467 api[860]: )
Jul 31 16:15:20 5d03591f8467 api[860]: OR EXISTS (
Jul 31 16:15:20 5d03591f8467 api[860]:         SELECT 1
Jul 31 16:15:20 5d03591f8467 api[860]:         FROM "role-has-permission" AS "permission.role-has-permission"
Jul 31 16:15:20 5d03591f8467 api[860]:         WHERE "permission"."id" = "permission.role-has-permission"."permission"
Jul 31 16:15:20 5d03591f8467 api[860]:         AND EXISTS (
Jul 31 16:15:20 5d03591f8467 api[860]:                 SELECT 1
Jul 31 16:15:20 5d03591f8467 api[860]:                 FROM "role" AS "permission.role-has-permission.role"
Jul 31 16:15:20 5d03591f8467 api[860]:                 WHERE "permission.role-has-permission"."role" = "permission.role-has-permission.role"."id"
Jul 31 16:15:20 5d03591f8467 api[860]:                 AND EXISTS (
Jul 31 16:15:20 5d03591f8467 api[860]:                         SELECT 1
Jul 31 16:15:20 5d03591f8467 api[860]:                         FROM "user-has-role" AS "permission.role-has-permission.role.user-has-role"
Jul 31 16:15:20 5d03591f8467 api[860]:                         WHERE "permission.role-has-permission.role"."id" = "permission.role-has-permission.role.user-has-role"."role"
Jul 31 16:15:20 5d03591f8467 api[860]:                         AND "permission.role-has-permission.role.user-has-role"."user" = $1
Jul 31 16:15:20 5d03591f8467 api[860]:                         AND ("permission.role-has-permission.role.user-has-role"."expiry date" IS NULL
Jul 31 16:15:20 5d03591f8467 api[860]:                         OR "permission.role-has-permission.role.user-has-role"."expiry date" > CURRENT_TIMESTAMP)
Jul 31 16:15:20 5d03591f8467 api[860]:                 )
Jul 31 16:15:20 5d03591f8467 api[860]:         )
Jul 31 16:15:20 5d03591f8467 api[860]: ))
Jul 31 16:15:20 5d03591f8467 api[860]: ORDER BY "permission"."name" ASC [ 2 ]
Jul 31 16:15:21 5d03591f8467 api[860]: Parsing GET /resin/user(2)?$select=actor,jwt_secret
Jul 31 16:15:21 5d03591f8467 api[860]: Running GET /resin/user(2)?$select=actor,jwt_secret
Jul 31 16:15:21 5d03591f8467 api[860]: SELECT "user"."actor", "user"."jwt secret" AS "jwt_secret"
Jul 31 16:15:21 5d03591f8467 api[860]: FROM "user"
Jul 31 16:15:21 5d03591f8467 api[860]: WHERE "user"."id" = $1 [ 2 ]
Jul 31 16:15:21 5d03591f8467 api[860]: Parsing GET /Auth/permission?$select=name&$filter=(is_of__user/any(uhp:(uhp/user eq @userId) and ((uhp/expiry_date eq null) or (uhp/expiry_date gt now())))) or (is_of__role/any(rhp:rhp/role/any(r:r/is_of__user/any(uhr:(uhr/user eq @userId) and ((uhr/expiry_date eq null) or (uhr/expiry_date gt now()))))))&$orderby=name asc&@userId=2
Jul 31 16:15:21 5d03591f8467 api[860]: Running GET /Auth/permission?$select=name&$filter=(is_of__user/any(uhp:(uhp/user eq @userId) and ((uhp/expiry_date eq null) or (uhp/expiry_date gt now())))) or (is_of__role/any(rhp:rhp/role/any(r:r/is_of__user/any(uhr:(uhr/user eq @userId) and ((uhr/expiry_date eq null) or (uhr/expiry_date gt now()))))))&$orderby=name asc&@userId=2
Jul 31 16:15:21 5d03591f8467 api[860]: SELECT "permission"."name"
Jul 31 16:15:21 5d03591f8467 api[860]: FROM "permission"
Jul 31 16:15:21 5d03591f8467 api[860]: WHERE (EXISTS (
Jul 31 16:15:21 5d03591f8467 api[860]:         SELECT 1
Jul 31 16:15:21 5d03591f8467 api[860]:         FROM "user-has-permission" AS "permission.user-has-permission"
Jul 31 16:15:21 5d03591f8467 api[860]:         WHERE "permission"."id" = "permission.user-has-permission"."permission"
Jul 31 16:15:21 5d03591f8467 api[860]:         AND "permission.user-has-permission"."user" = $1
Jul 31 16:15:21 5d03591f8467 api[860]:         AND ("permission.user-has-permission"."expiry date" IS NULL
Jul 31 16:15:21 5d03591f8467 api[860]:         OR "permission.user-has-permission"."expiry date" > CURRENT_TIMESTAMP)
Jul 31 16:15:21 5d03591f8467 api[860]: )
Jul 31 16:15:21 5d03591f8467 api[860]: OR EXISTS (
Jul 31 16:15:21 5d03591f8467 api[860]:         SELECT 1
Jul 31 16:15:21 5d03591f8467 api[860]:         FROM "role-has-permission" AS "permission.role-has-permission"
Jul 31 16:15:21 5d03591f8467 api[860]:         WHERE "permission"."id" = "permission.role-has-permission"."permission"
Jul 31 16:15:21 5d03591f8467 api[860]:         AND EXISTS (
Jul 31 16:15:21 5d03591f8467 api[860]:                 SELECT 1
Jul 31 16:15:21 5d03591f8467 api[860]:                 FROM "role" AS "permission.role-has-permission.role"
Jul 31 16:15:21 5d03591f8467 api[860]:                 WHERE "permission.role-has-permission"."role" = "permission.role-has-permission.role"."id"
Jul 31 16:15:21 5d03591f8467 api[860]:                 AND EXISTS (
Jul 31 16:15:21 5d03591f8467 api[860]:                         SELECT 1
Jul 31 16:15:21 5d03591f8467 api[860]:                         FROM "user-has-role" AS "permission.role-has-permission.role.user-has-role"
Jul 31 16:15:21 5d03591f8467 api[860]:                         WHERE "permission.role-has-permission.role"."id" = "permission.role-has-permission.role.user-has-role"."role"
Jul 31 16:15:21 5d03591f8467 api[860]:                         AND "permission.role-has-permission.role.user-has-role"."user" = $1
Jul 31 16:15:21 5d03591f8467 api[860]:                         AND ("permission.role-has-permission.role.user-has-role"."expiry date" IS NULL
Jul 31 16:15:21 5d03591f8467 api[860]:                         OR "permission.role-has-permission.role.user-has-role"."expiry date" > CURRENT_TIMESTAMP)
Jul 31 16:15:21 5d03591f8467 api[860]:                 )
Jul 31 16:15:21 5d03591f8467 api[860]:         )
Jul 31 16:15:21 5d03591f8467 api[860]: ))
Jul 31 16:15:21 5d03591f8467 api[860]: ORDER BY "permission"."name" ASC [ 2 ]
Jul 31 16:15:21 5d03591f8467 api[860]: Parsing GET /resin/device?$filter=startswith(uuid,%2799cd956%27)&$select=device_name,id,device_type,overall_status,is_online,ip_address,mac_address,last_connectivity_event,uuid,is_on__commit,supervisor_version,is_web_accessible,note,os_version&$expand=belongs_to__application($select=app_name)
Jul 31 16:15:21 5d03591f8467 api[860]: Failed to translate url:  {
Jul 31 16:15:21 5d03591f8467 api[860]:         "resource": "device",
Jul 31 16:15:21 5d03591f8467 api[860]:         "options": {
Jul 31 16:15:21 5d03591f8467 api[860]:                 "$filter": [
Jul 31 16:15:21 5d03591f8467 api[860]:                         "call",
Jul 31 16:15:21 5d03591f8467 api[860]:                         {
Jul 31 16:15:21 5d03591f8467 api[860]:                                 "args": [
Jul 31 16:15:21 5d03591f8467 api[860]:                                         {
Jul 31 16:15:21 5d03591f8467 api[860]:                                                 "name": "uuid",
Jul 31 16:15:21 5d03591f8467 api[860]:                                                 "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                         },
Jul 31 16:15:21 5d03591f8467 api[860]:                                         {
Jul 31 16:15:21 5d03591f8467 api[860]:                                                 "bind": 0
Jul 31 16:15:21 5d03591f8467 api[860]:                                         }
Jul 31 16:15:21 5d03591f8467 api[860]:                                 ],
Jul 31 16:15:21 5d03591f8467 api[860]:                                 "method": "startswith"
Jul 31 16:15:21 5d03591f8467 api[860]:                         }
Jul 31 16:15:21 5d03591f8467 api[860]:                 ],
Jul 31 16:15:21 5d03591f8467 api[860]:                 "$select": {
Jul 31 16:15:21 5d03591f8467 api[860]:                         "properties": [
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "device_name",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "id",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "device_type",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "overall_status",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "is_online",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "ip_address",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "mac_address",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "last_connectivity_event",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "uuid",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "is_on__commit",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "supervisor_version",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "is_web_accessible",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "note",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "os_version",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                 }
Jul 31 16:15:21 5d03591f8467 api[860]:                         ]
Jul 31 16:15:21 5d03591f8467 api[860]:                 },
Jul 31 16:15:21 5d03591f8467 api[860]:                 "$expand": {
Jul 31 16:15:21 5d03591f8467 api[860]:                         "properties": [
Jul 31 16:15:21 5d03591f8467 api[860]:                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "name": "belongs_to__application",
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "property": null,
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "count": null,
Jul 31 16:15:21 5d03591f8467 api[860]:                                         "options": {
Jul 31 16:15:21 5d03591f8467 api[860]:                                                 "$select": {
Jul 31 16:15:21 5d03591f8467 api[860]:                                                         "properties": [
Jul 31 16:15:21 5d03591f8467 api[860]:                                                                 {
Jul 31 16:15:21 5d03591f8467 api[860]:                                                                         "name": "app_name",
Jul 31 16:15:21 5d03591f8467 api[860]:                                                                         "property": null
Jul 31 16:15:21 5d03591f8467 api[860]:                                                                 }
Jul 31 16:15:21 5d03591f8467 api[860]:                                                         ]
Jul 31 16:15:21 5d03591f8467 api[860]:                                                 }
Jul 31 16:15:21 5d03591f8467 api[860]:                                         }
Jul 31 16:15:21 5d03591f8467 api[860]:                                 }
Jul 31 16:15:21 5d03591f8467 api[860]:                         ]
Jul 31 16:15:21 5d03591f8467 api[860]:                 }
Jul 31 16:15:21 5d03591f8467 api[860]:         }
Jul 31 16:15:21 5d03591f8467 api[860]: } GET SyntaxError: Could not resolve relationship mapping
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.ResolveRelationship (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:514:19)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.ReferencedField (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:562:46)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.AliasSelectField (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:546:38)
Jul 31 16:15:21 5d03591f8467 api[860]:     at AddSelectFields._.reject.map.field (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:532:36)
Jul 31 16:15:21 5d03591f8467 api[860]:     at arrayMap (/usr/src/app/node_modules/lodash/lodash.js:639:23)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Function.map (/usr/src/app/node_modules/lodash/lodash.js:9556:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at interceptor (/usr/src/app/node_modules/lodash/lodash.js:16993:35)
Jul 31 16:15:21 5d03591f8467 api[860]:     at thru (/usr/src/app/node_modules/lodash/lodash.js:8797:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/lodash/lodash.js:4374:28
Jul 31 16:15:21 5d03591f8467 api[860]:     at arrayReduce (/usr/src/app/node_modules/lodash/lodash.js:683:21)
Jul 31 16:15:21 5d03591f8467 api[860]:     at baseWrapperValue (/usr/src/app/node_modules/lodash/lodash.js:4373:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at LazyWrapper.lazyValue [as value] (/usr/src/app/node_modules/lodash/lodash.js:1859:16)
Jul 31 16:15:21 5d03591f8467 api[860]:     at baseWrapperValue (/usr/src/app/node_modules/lodash/lodash.js:4371:25)
Jul 31 16:15:21 5d03591f8467 api[860]:     at LodashWrapper.wrapperValue (/usr/src/app/node_modules/lodash/lodash.js:9052:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.AddSelectFields (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:533:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.PathSegment (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:351:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.match (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:177:32)
Jul 31 16:15:21 5d03591f8467 api[860]:     at memoizeWeak (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:55:51)
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/es5-ext/function/#/partial.js:14:16
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/memoizee/lib/configure-map.js:61:24
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/memoizee/lib/weak.js:87:21
Jul 31 16:15:21 5d03591f8467 api[860]:     at memoizedOdata2AbstractSQL (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:78:56)
Jul 31 16:15:21 5d03591f8467 api[860]:     at exports.translateUri (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:184:34)
Jul 31 16:15:21 5d03591f8467 api[860]:     at tryCatcher (/usr/src/app/node_modules/bluebird/js/release/util.js:16:23)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:512:31)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at MappingPromiseArray.PromiseArray._resolve (/usr/src/app/node_modules/bluebird/js/release/promise_array.js:126:19)
Jul 31 16:15:21 5d03591f8467 api[860]:     at MappingPromiseArray._promiseFulfilled (/usr/src/app/node_modules/bluebird/js/release/map.js:101:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:574:26)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Holder$2._callFunction (<anonymous>:19:29)
Jul 31 16:15:21 5d03591f8467 api[860]:     at _drainQueueStep (/usr/src/app/node_modules/bluebird/js/release/async.js:142:12)
Jul 31 16:15:21 5d03591f8467 api[860]:     at _drainQueue (/usr/src/app/node_modules/bluebird/js/release/async.js:131:9)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Async._drainQueues (/usr/src/app/node_modules/bluebird/js/release/async.js:147:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Immediate.Async.drainQueues [as _onImmediate] (/usr/src/app/node_modules/bluebird/js/release/async.js:17:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at runCallback (timers.js:705:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at tryOnImmediate (timers.js:676:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at processImmediate (timers.js:658:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at process.topLevelDomainCallback (domain.js:120:23)
Jul 31 16:15:21 5d03591f8467 api[860]:  SyntaxError: Could not resolve relationship mapping
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.ResolveRelationship (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:514:19)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.ReferencedField (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:562:46)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.AliasSelectField (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:546:38)
Jul 31 16:15:21 5d03591f8467 api[860]:     at AddSelectFields._.reject.map.field (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:532:36)
Jul 31 16:15:21 5d03591f8467 api[860]:     at arrayMap (/usr/src/app/node_modules/lodash/lodash.js:639:23)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Function.map (/usr/src/app/node_modules/lodash/lodash.js:9556:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at interceptor (/usr/src/app/node_modules/lodash/lodash.js:16993:35)
Jul 31 16:15:21 5d03591f8467 api[860]:     at thru (/usr/src/app/node_modules/lodash/lodash.js:8797:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/lodash/lodash.js:4374:28
Jul 31 16:15:21 5d03591f8467 api[860]:     at arrayReduce (/usr/src/app/node_modules/lodash/lodash.js:683:21)
Jul 31 16:15:21 5d03591f8467 api[860]:     at baseWrapperValue (/usr/src/app/node_modules/lodash/lodash.js:4373:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at LazyWrapper.lazyValue [as value] (/usr/src/app/node_modules/lodash/lodash.js:1859:16)
Jul 31 16:15:21 5d03591f8467 api[860]:     at baseWrapperValue (/usr/src/app/node_modules/lodash/lodash.js:4371:25)
Jul 31 16:15:21 5d03591f8467 api[860]:     at LodashWrapper.wrapperValue (/usr/src/app/node_modules/lodash/lodash.js:9052:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.AddSelectFields (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:533:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.PathSegment (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:351:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at OData2AbstractSQL.match (/usr/src/app/node_modules/@resin/odata-to-abstract-sql/out/odata-to-abstract-sql.js:177:32)
Jul 31 16:15:21 5d03591f8467 api[860]:     at memoizeWeak (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:55:51)
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/es5-ext/function/#/partial.js:14:16
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/memoizee/lib/configure-map.js:61:24
Jul 31 16:15:21 5d03591f8467 api[860]:     at /usr/src/app/node_modules/memoizee/lib/weak.js:87:21
Jul 31 16:15:21 5d03591f8467 api[860]:     at memoizedOdata2AbstractSQL (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:78:56)
Jul 31 16:15:21 5d03591f8467 api[860]:     at exports.translateUri (/usr/src/app/node_modules/@resin/pinejs/out/sbvr-api/uri-parser.js:184:34)
Jul 31 16:15:21 5d03591f8467 api[860]:     at tryCatcher (/usr/src/app/node_modules/bluebird/js/release/util.js:16:23)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:512:31)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at MappingPromiseArray.PromiseArray._resolve (/usr/src/app/node_modules/bluebird/js/release/promise_array.js:126:19)
Jul 31 16:15:21 5d03591f8467 api[860]:     at MappingPromiseArray._promiseFulfilled (/usr/src/app/node_modules/bluebird/js/release/map.js:101:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:574:26)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:524:17)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:569:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:614:10)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:694:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:638:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Promise._resolveCallback (/usr/src/app/node_modules/bluebird/js/release/promise.js:432:57)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Holder$2._callFunction (<anonymous>:19:29)
Jul 31 16:15:21 5d03591f8467 api[860]:     at _drainQueueStep (/usr/src/app/node_modules/bluebird/js/release/async.js:142:12)
Jul 31 16:15:21 5d03591f8467 api[860]:     at _drainQueue (/usr/src/app/node_modules/bluebird/js/release/async.js:131:9)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Async._drainQueues (/usr/src/app/node_modules/bluebird/js/release/async.js:147:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at Immediate.Async.drainQueues [as _onImmediate] (/usr/src/app/node_modules/bluebird/js/release/async.js:17:14)
Jul 31 16:15:21 5d03591f8467 api[860]:     at runCallback (timers.js:705:18)
Jul 31 16:15:21 5d03591f8467 api[860]:     at tryOnImmediate (timers.js:676:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at processImmediate (timers.js:658:5)
Jul 31 16:15:21 5d03591f8467 api[860]:     at process.topLevelDomainCallback (domain.js:120:23)
Jul 31 16:15:27 5d03591f8467 api[860]: Parsing PATCH /resin/service_instance(44)
Jul 31 16:15:27 5d03591f8467 api[860]: Running PATCH /resin/service_instance(44)
Jul 31 16:15:27 5d03591f8467 api[860]: UPDATE "service instance"
Jul 31 16:15:27 5d03591f8467 api[860]: SET "last heartbeat" = $1
Jul 31 16:15:27 5d03591f8467 api[860]: WHERE "service instance"."id" = $2 [ 2020-07-31T16:15:27.649Z, 44 ]

Specifications

Additional References

pdcastro commented 4 years ago

Starting with a disclaimer: Neither Homebrew nor Node v14 are "officially" supported by the balena CLI, in fact I am aware that some CLI commands don't work with Node v14. (The balena-cli distribution over Homebrew has been independently setup and maintained by a balena user.) The officially supported installation options are documented at: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md

Having said that, the balena device command "works for me" with macOS Mojave (10.14.6) and Node v14.3.0 (same as yours), even when using Homebrew:

$ brew install balena-cli

$ ls -l /usr/local/bin/balena
lrwxr-xr-x  1 paulo  admin  39 31 Jul 17:24 /usr/local/bin/balena -> ../Cellar/balena-cli/12.10.0/bin/balena

$ $ /usr/local/bin/balena version -a
balena-cli version "12.10.0"
Node.js version "14.3.0"

$ /usr/local/bin/balena device dcbff32a --debug
[debug] new argv=[/Users/paulo/.nvm/versions/node/v14.3.0/bin/node,/usr/local/bin/balena,device,dcbff32a] length=4
== FROSTY SNOW
ID:                 1958859
DEVICE TYPE:        raspberrypi4-64
STATUS:             offline
...

Also, not using Homebrew, and using instead nvm:

$ nvm use 14.3.0
Now using node v14.3.0 (npm v6.14.5)

$ node --version
v14.3.0

$ npm install -g --production --unsafe-perm balena-cli

$ which balena
/Users/paulo/.nvm/versions/node/v14.3.0/bin/balena

$ balena device b1878c6
== 94:C6:91:A1:68:22 PDCASTRO
ID:                 1616110
DEVICE TYPE:        intel-nuc
STATUS:             idle
IS ONLINE:          true
...

I suggest you try using the graphical installer for macOS, which I've just successfully tested here as well. It bundles its own Node.js (currently Node.js v10.21.0), and avoids most installation issues.

Also, the error you were getting was BalenaRequestError: Request error: Internal Server Error. Could it have been a temporary balenaCloud backend glitch that got sorted by now?

pdcastro commented 4 years ago

@jimmyw, those API logs are from openBalena, right? Now it rings a bell. I think the issue may be an incompatibility with the balena SDK version used by recent versions of balena CLI. Could you try downgrading balena CLI to version 12.3.3? - https://github.com/balena-io/balena-cli/releases?after=v12.3.4

PastaGringo commented 4 years ago

I confirm it's working with CLI v12.3.3

jimmyw commented 4 years ago

@pdcastro Sorry, I forgot to mention its open balena.

Yes, it's stopped working after an upgrade, I can absolutely give the old version a try.

jimmyw commented 4 years ago

@pdcastro

Maybe you can help, if i check out v12.3.3 and run

$ npm install balena-cli -g

I will still end up with balena-cli 12.10.1, tried to flush the full npm folder, but same result.

pdcastro commented 4 years ago

I will still end up with balena-cli 12.10.1

It's probably a case of multiple installations. A command that may help identify what is installed is which balena:

$ which balena
/Users/paulo/.nvm/versions/node/v14.3.0/bin/balena

vs.

$ which balena
/usr/local/bin/balena

The latter would be the Homebrew installation:

$ ls -l /usr/local/bin/balena
lrwxr-xr-x  1 paulo  admin  39 31 Jul 17:24 /usr/local/bin/balena -> ../Cellar/balena-cli/12.10.0/bin/balena

(The Cellar folder in the path indicates Homebrew.)

Perhaps uninstall the brew installation:

$ brew uninstall balena-cli
Uninstalling /usr/local/Cellar/balena-cli/12.10.0... (42,548 files, 345.9MB)

In some rare cases, which balena indicates one path but running balena actually runs something else. I am not sure why, but from experience it gets resolved by closing the command terminal window and opening a new fresh one. Also, to be completely sure of what balena is being executed, use the full path:

# the output below was actually captured for the macOS graphical installer
$ /usr/local/bin/balena version -a
balena-cli version "12.10.1"
Node.js version "10.21.0"

$ /Users/paulo/.nvm/versions/node/v14.3.0/bin/balena version -a
balena-cli version "12.10.1"
Node.js version "14.3.0"

By the way, if using the npm installation method, I suggest using Node.js v10 or Node.js v12, which are better tested and supported by the balena CLI. And to install Node.js, I suggest using nvm (not to be confused with npm, note the middle character!).

$ nvm install 12
Downloading and installing node v12.18.3...
...

$ nvm use 12
Now using node v12.18.3 (npm v6.14.6)

$ node --version
v12.18.3

$ npm i -g --production --unsafe-perm balena-cli@12.3.3
+ balena-cli@12.3.3
added 2345 packages from 1949 contributors in 49.774s

$ which balena
/Users/paulo/.nvm/versions/node/v12.18.3/bin/balena

21:14 $ balena version -a
balena-cli version "12.3.3"
Node.js version "12.18.3"
pdcastro commented 4 years ago

Also I should add: It sounds like you prefer the brew or npm installation methods, which is fine, but the least troublesome installation options are either the standalone zip file for macOS or the native/graphical macOS installer, as documented, mainly because they bundle their own copy of Node.js with the installer (and that copy of Node.js will not interfere with the system installation or with nvm). (And the installers are available in the releases page for any CLI version, including v12.3.3.)

jimmyw commented 4 years ago

I switched to my ubuntu machine, but have the same issue here

$ balena --version -a
balena-cli version "12.10.1"
Node.js version "10.22.0"
$ cat ~/.npmrc 
prefix = /home/jimmy/.npm-packages
$ which balena
/home/jimmy/.npm-packages/bin/balena
$ rm -rf ~/.npm-packages
$ balena --version
bash: /home/jimmy/.npm-packages/bin/balena: No such file or directory
$ git co v12.3.3
HEAD is now at 21c8a38c v12.3.3
$ git branch
* (HEAD detached at v12.3.3)
$ git clean -xfd
$ npm install -g balena-cli
<lots of output ...>
$ balena --version -a
balena-cli version "12.10.1"
Node.js version "10.22.0"

This is really strange to me, are there any caches I missed?

pdcastro commented 4 years ago

$ git co v12.3.3 $ npm install -g balena-cli

Those two commands don't usually go together: It is not necessary to git clone the balena-cli repo in order to install the balena CLI "globally" with the npm install -g command (the -g flag), even if installing older versions of the CLI.

The following command specifically will install the latest version of the CLI (12.10.1), regardless of git co v12.3.3:

$ npm install -g balena-cli

To install the v12.3.3 of the balena CLI globally, append @12.3.3 to the package name:

$ npm install -g --production balena-cli@12.3.3

--production will save some 200MB (?) disk space, and --unsafe-perm is useful if running as the root user.

There is no need to git clone / git checkout unless you are planning to modify the CLI source code (btw, contributions are welcome!). :-)

jimmyw commented 4 years ago

@pdcastro

Ok, thanks for the clarification.

I did actually want to modify the code, I tried to add additional logging but failed to test it, how do you build from the current git sources?

jimmyw commented 4 years ago

12.3.3 failed :(

$ npm install -g --production balena-cli@12.3.3
/home/jimmy/.npm-packages/bin/balena -> /home/jimmy/.npm-packages/lib/node_modules/balena-cli/bin/balena

> balena-cli@12.3.3 postinstall /home/jimmy/.npm-packages/lib/node_modules/balena-cli
> patch-package --patch-dir patches0 && patch-package

patch-package 6.2.2
Applying patches...
patch-package@6.2.2 āœ”
patch-package 6.2.2
Applying patches...

**ERROR** Failed to apply patch for package @oclif/dev-cli at path

    node_modules/@oclif/dev-cli

  This error was caused because patch-package cannot apply the following patch file:

    patches/@oclif+dev-cli+1.22.0.dev.patch

  Try removing node_modules and trying again. If that doesn't work, maybe there was
  an accidental change made to the patch file? Try recreating it by manually
  editing the appropriate files and running:

    patch-package @oclif/dev-cli

  If that doesn't work, then it's a bug in patch-package, so please submit a bug
  report. Thanks!

    https://github.com/ds300/patch-package/issues

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/balena-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/balena-cli/node_modules/livepush/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: winusb-driver-generator@1.2.4 (node_modules/balena-cli/node_modules/winusb-driver-generator):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for winusb-driver-generator@1.2.4: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: macmount@1.0.0 (node_modules/balena-cli/node_modules/macmount):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for macmount@1.0.0: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ balena-cli@12.3.3
added 8 packages from 6 contributors and updated 1 package in 3.969s
pdcastro commented 4 years ago

I did actually want to modify the code

Oh, that's cool! Start by having a look at the Contributing document. In this case, don't use the -g flag to the npm install command, or any other arguments really:

$ git co v12.3.3
$ npm install

Then follow it with npm run build, and run the CLI with ./bin/balena:

$ git co v12.3.3
$ npm install
$ npm run build
$ ./bin/balena version -a
balena-cli version "12.10.0"
Node.js version "10.22.0"
pdcastro commented 4 years ago

ERROR Failed to apply patch for package @oclif/dev-cli at path

See this issue: https://github.com/balena-io/balena-cli/issues/1751 Basically, when changing between CLI versions (whether downgrading or upgrading) and installing via npm, it may be necessary to the delete the relevant node_modules folder.

jimmyw commented 4 years ago

Thanks for your patience with me :)

jimmyw commented 4 years ago

Okay, i can confirm that $ balena device works with version 12.3.3.

I hope this is helpful!

pdcastro commented 4 years ago

I hope this is helpful!

Yes, thank you for creating this issue! I am labelling it as a bug in the balena CLI, although the underlying issue seems to be that openBalena releases have not kept up with recent changes to the balena SDK. There is an ongoing internal discussion on how to address this.

pdcastro commented 4 years ago

cc: @thgreasi, @Page-, @srlowe : The workaround for this issue (SDK / openBalena compatibility) was to downgrade the CLI to v12.3.3.

thgreasi commented 4 years ago

I see @pdcastro . It looks like it's the overall_status that's breaking the requests. Here is the respective open-balena issue See: https://github.com/balena-io/open-balena-api/issues/338

pdcastro commented 4 years ago

@thgreasi, @Page-, @srlowe, FYI, a complication with the current advice to openBalena users to downgrade to v12.3.3 is that that version is affected by the PinejsClientCore bug in commands like balena scan and balena config inject. See issue #1971. Also: internal flowdock thread.

thgreasi commented 4 years ago

@pdcastro based on the changelog, maybe they can try using v12.2.2. Looks promising to me wrt the the balena-pine <-> pine-client-core issue.

pdcastro commented 3 years ago

openBalena version 3 has been released, šŸŽ‰
https://github.com/balena-io/open-balena/blob/master/CHANGELOG.md

It includes support for the new API endpoints and newer versions of the balena SDK, and therefore the latest CLI releases. I have tested openBalena v3 with CLI v12.25.6 (currently the latest version), and the balena device command in particular was successful:

$ balena device 7d0cb2c
== BOLD PAPER
ID:                    2
DEVICE TYPE:           raspberrypi3
STATUS:                idle
IS ONLINE:             true
IP ADDRESS:            192.168.1.36
MAC ADDRESS:           B8:27:EB:94:74:69 B8:27:EB:C1:21:3C
APPLICATION NAME:      myApp
LAST SEEN:             2020-10-29T02:17:13.200Z
UUID:                  7d0cb2cb6e2e84ca7e75e554a9a8069b
COMMIT:                N/a
SUPERVISOR VERSION:    11.14.0
IS WEB ACCESSIBLE:     false
OS VERSION:            balenaOS 2.58.3+rev1
DASHBOARD URL:         https://dashboard.vestamon.co.uk/devices/7d0cb2cb6e2e84ca7e75e554a9a8069b/summary
CPU USAGE PERCENT:     6
CPU TEMP C:            45
CPU ID:                000000000894746
MEMORY USAGE MB:       278
MEMORY TOTAL MB:       745
MEMORY USAGE PERCENT:  37
STORAGE BLOCK DEVICE:  /dev/mmcblk0
STORAGE USAGE MB:      74
STORAGE TOTAL MB:      13929
STORAGE USAGE PERCENT: 1

For older versions of openBalena (older than v3.0.0), the recommendation remains to downgrade the CLI to v12.2.2.