Open Balena: GET SyntaxError: Could not match resource

Intermittent errors on Open Balena API container, in the journalctl logs. Running v3.2.1. It results in CPU spikes which is how I came across it, but haven’t noticed any other repercussions:

Apr 22 03:19:24 b4a37b483439 api[982]: 2021-04-22T03:19:24.445Z 24.67.185.146 a/117 GET /resin/supervisor_release?$select=supervisor_version,image_name&$filter=should_manage__device/any(d:d/uuid%20eq%20'9
Apr 22 03:19:24 b4a37b483439 api[982]:     at handleODataRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1089:21)
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1024:20
Apr 22 03:19:24 b4a37b483439 api[982]:     at mapTill (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/control-flow.ts:45:19)
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1030:16
Apr 22 03:19:24 b4a37b483439 api[982]:     at processTicksAndRejections (internal/process/task_queues.js:93:5)
Apr 22 03:19:24 b4a37b483439 api[982]:     at runMicrotasks (<anonymous>)
Apr 22 03:19:24 b4a37b483439 api[982]:     at prepareRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1014:48)
Apr 22 03:19:24 b4a37b483439 api[982]:     at Object.translateUri (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:404:28)
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:242:50
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/memoizee/lib/weak.js:87:21
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/memoizee/lib/configure-map.js:61:24
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/es5-ext/function/#/partial.js:12:16
Apr 22 03:19:24 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:165:43
Apr 22 03:19:24 b4a37b483439 api[982]:     at OData2AbstractSQL.match (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:337:24)
Apr 22 03:19:24 b4a37b483439 api[982]:     at OData2AbstractSQL.PathSegment (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:383:25)
Apr 22 03:19:24 b4a37b483439 api[982]:     at OData2AbstractSQL.Resource (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:751:10)
Apr 22 03:19:24 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 22 03:19:24 b4a37b483439 api[982]:         }
Apr 22 03:19:24 b4a37b483439 api[982]:                 }
Apr 22 03:19:24 b4a37b483439 api[982]:                         }
Apr 22 03:19:24 b4a37b483439 api[982]:                                 "method": "any"
Apr 22 03:19:24 b4a37b483439 api[982]:                                 "identifier": "d",
Apr 22 03:19:24 b4a37b483439 api[982]:                                 ],
Apr 22 03:19:24 b4a37b483439 api[982]:                                         }
Apr 22 03:19:24 b4a37b483439 api[982]:                                                 "bind": 0
Apr 22 03:19:24 b4a37b483439 api[982]:                                         {
Apr 22 03:19:24 b4a37b483439 api[982]:                                         },
Apr 22 03:19:24 b4a37b483439 api[982]:                                                 "count": null
Apr 22 03:19:24 b4a37b483439 api[982]:                                                 },
Apr 22 03:19:24 b4a37b483439 api[982]:                                                         "count": null
Apr 22 03:19:24 b4a37b483439 api[982]:                                                         "property": null,
Apr 22 03:19:24 b4a37b483439 api[982]:                                                         "name": "uuid",
Apr 22 03:19:24 b4a37b483439 api[982]:                                                 "property": {
Apr 22 03:19:24 b4a37b483439 api[982]:                                                 "name": "d",
Apr 22 03:19:24 b4a37b483439 api[982]:                                         {
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "eq",
Apr 22 03:19:24 b4a37b483439 api[982]:                                 "expression": [
Apr 22 03:19:24 b4a37b483439 api[982]:                         "lambda": {
Apr 22 03:19:24 b4a37b483439 api[982]:                         "name": "should_manage__device",
Apr 22 03:19:24 b4a37b483439 api[982]:                 "$filter": {
Apr 22 03:19:24 b4a37b483439 api[982]:                 },
Apr 22 03:19:24 b4a37b483439 api[982]:                         ]
Apr 22 03:19:24 b4a37b483439 api[982]:                                 }
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "count": null
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "property": null,
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "name": "image_name",
Apr 22 03:19:24 b4a37b483439 api[982]:                                 {
Apr 22 03:19:24 b4a37b483439 api[982]:                                 },
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "count": null
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "property": null,
Apr 22 03:19:24 b4a37b483439 api[982]:                                         "name": "supervisor_version",
Apr 22 03:19:24 b4a37b483439 api[982]:                                 {
Apr 22 03:19:24 b4a37b483439 api[982]:                         "properties": [
Apr 22 03:19:24 b4a37b483439 api[982]:                 "$select": {
Apr 22 03:19:24 b4a37b483439 api[982]:         "options": {
Apr 22 03:19:24 b4a37b483439 api[982]:         "resource": "supervisor_release",
Apr 22 03:19:24 b4a37b483439 api[982]: Failed to translate url:  {

Seems like it happens at unpredictable intervals:

Apr 12 23:56:51 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 13 01:53:38 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 13 06:40:35 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 14 06:40:40 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 15 06:40:44 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 16 06:40:49 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 17 06:40:53 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 19 03:19:11 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 20 03:19:15 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 21 03:19:19 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 22 03:19:24 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource

Hello, looks like that request line is truncated, but the device id begins with 9. Are you able to manually run this request from the command line using curl with the correct uuid and see what the API responds with please:

curl "https://api.<your-open-balena.tld>/resin/supervisor_release?\$filter=should_manage__device/any(d:d/uuid%20eq%20'<your-device-id>')" -H "Content-Type: application/json" -H "Authorization: Bearer <your-api-token-or-session-token-from-dashboard>"

This is for OpenBalena. What/where would ‘your-api-token-or-session-token-from-dashboard’ be?

I also have a device id 964f2e39faea9920d7fa3574936f3bd6, which I assume is the one it is trying. The error isn’t caused by any particular action though, so not really sure what it is trying to do when the error occurs, or what device it is doing it to.

And may have been me not copying the logs correctly. Here is another without truncation and as it appears in the logs:

Apr 29 03:19:41 b4a37b483439 api[982]: 2021-04-29T03:19:41.329Z 172.20.0.8 s/vpn PATCH /resin/service_instance(71) 200 35.734ms -
Apr 29 03:19:51 b4a37b483439 api[982]: 2021-04-29T03:19:51.363Z 172.20.0.8 s/vpn PATCH /resin/service_instance(71) 200 21.071ms -
Apr 29 03:19:53 b4a37b483439 api[982]: Failed to translate url:  {
Apr 29 03:19:53 b4a37b483439 api[982]:         "resource": "supervisor_release",
Apr 29 03:19:53 b4a37b483439 api[982]:         "options": {
Apr 29 03:19:53 b4a37b483439 api[982]:                 "$select": {
Apr 29 03:19:53 b4a37b483439 api[982]:                         "properties": [
Apr 29 03:19:53 b4a37b483439 api[982]:                                 {
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "name": "supervisor_version",
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "property": null,
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "count": null
Apr 29 03:19:53 b4a37b483439 api[982]:                                 },
Apr 29 03:19:53 b4a37b483439 api[982]:                                 {
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "name": "image_name",
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "property": null,
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "count": null
Apr 29 03:19:53 b4a37b483439 api[982]:                                 }
Apr 29 03:19:53 b4a37b483439 api[982]:                         ]
Apr 29 03:19:53 b4a37b483439 api[982]:                 },
Apr 29 03:19:53 b4a37b483439 api[982]:                 "$filter": {
Apr 29 03:19:53 b4a37b483439 api[982]:                         "name": "should_manage__device",
Apr 29 03:19:53 b4a37b483439 api[982]:                         "lambda": {
Apr 29 03:19:53 b4a37b483439 api[982]:                                 "expression": [
Apr 29 03:19:53 b4a37b483439 api[982]:                                         "eq",
Apr 29 03:19:53 b4a37b483439 api[982]:                                         {
Apr 29 03:19:53 b4a37b483439 api[982]:                                                 "name": "d",
Apr 29 03:19:53 b4a37b483439 api[982]:                                                 "property": {
Apr 29 03:19:53 b4a37b483439 api[982]:                                                         "name": "uuid",
Apr 29 03:19:53 b4a37b483439 api[982]:                                                         "property": null,
Apr 29 03:19:53 b4a37b483439 api[982]:                                                         "count": null
Apr 29 03:19:53 b4a37b483439 api[982]:                                                 },
Apr 29 03:19:53 b4a37b483439 api[982]:                                                 "count": null
Apr 29 03:19:53 b4a37b483439 api[982]:                                         },
Apr 29 03:19:53 b4a37b483439 api[982]:                                         {
Apr 29 03:19:53 b4a37b483439 api[982]:                                                 "bind": 0
Apr 29 03:19:53 b4a37b483439 api[982]:                                         }
Apr 29 03:19:53 b4a37b483439 api[982]:                                 ],
Apr 29 03:19:53 b4a37b483439 api[982]:                                 "identifier": "d",
Apr 29 03:19:53 b4a37b483439 api[982]:                                 "method": "any"
Apr 29 03:19:53 b4a37b483439 api[982]:                         }
Apr 29 03:19:53 b4a37b483439 api[982]:                 }
Apr 29 03:19:53 b4a37b483439 api[982]:         }
Apr 29 03:19:53 b4a37b483439 api[982]: } GET SyntaxError: Could not match resource
Apr 29 03:19:53 b4a37b483439 api[982]:     at OData2AbstractSQL.Resource (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:751:10)
Apr 29 03:19:53 b4a37b483439 api[982]:     at OData2AbstractSQL.PathSegment (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:383:25)
Apr 29 03:19:53 b4a37b483439 api[982]:     at OData2AbstractSQL.match (/usr/src/app/node_modules/@balena/odata-to-abstract-sql/src/odata-to-abstract-sql.ts:337:24)
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:165:43
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/es5-ext/function/#/partial.js:12:16
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/memoizee/lib/configure-map.js:61:24
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/memoizee/lib/weak.js:87:21
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:242:50
Apr 29 03:19:53 b4a37b483439 api[982]:     at Object.translateUri (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/uri-parser.ts:404:28)
Apr 29 03:19:53 b4a37b483439 api[982]:     at prepareRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1014:48)
Apr 29 03:19:53 b4a37b483439 api[982]:     at processTicksAndRejections (internal/process/task_queues.js:93:5)
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1030:16
Apr 29 03:19:53 b4a37b483439 api[982]:     at mapTill (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/control-flow.ts:45:19)
Apr 29 03:19:53 b4a37b483439 api[982]:     at /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1024:20
Apr 29 03:19:53 b4a37b483439 api[982]:     at handleODataRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1089:21)
Apr 29 03:19:53 b4a37b483439 api[982]: 2021-04-29T03:19:53.481Z 24.67.185.146 a/117 GET /resin/supervisor_release?$select=supervisor_version,image_name&$filter=should_manage__device/any(d:d/uuid%20eq%20'964f2e39faea9920d7fa3574936f3bd6') 500 35.863ms -

I’m not really sure what the command that is failing does. But a few unique environmental factors sprung to mind. This device is an orange pi zero using the image from the staging page run on open balena. Not sure if the fact it is a staging image makes a difference.

Another error, I think unrelated and covered by a coming pull request, but logging just in case relevant. Even with production mode it didn’t recover:

May 08 17:59:34 b4a37b483439 systemd[1]: open-balena-api.service: Job open-balena-api.service/start failed with result 'dependency'.
May 08 17:59:34 b4a37b483439 systemd[1]: Dependency failed for open-balena-api.
May 08 17:59:34 b4a37b483439 systemd[1]: Failed to start Confd.
May 08 17:59:34 b4a37b483439 systemd[1]: confd.service: Failed with result 'exit-code'.
May 08 17:59:34 b4a37b483439 systemd[1]: confd.service: Main process exited, code=exited, status=219/CGROUP
May 08 17:59:34 b4a37b483439 systemd[1523]: confd.service: Failed at step CGROUP spawning /usr/local/bin/confd: No such file or directory
May 08 17:59:34 b4a37b483439 systemd[1523]: confd.service: Failed to attach to cgroup /system.slice/containerd.service/system.slice/confd.service: No such file or directory
May 08 17:59:34 b4a37b483439 systemd[1]: Starting Confd...
May 08 17:59:34 b4a37b483439 systemd[1]: Stopped open-balena-api.
May 08 17:59:34 b4a37b483439 systemd[1]: open-balena-api.service: Scheduled restart job, restart counter is at 1.
May 08 17:59:34 b4a37b483439 systemd[1]: open-balena-api.service: Service RestartSec=100ms expired, scheduling restart.
May 08 17:59:33 b4a37b483439 systemd[1]: open-balena-api.service: Failed with result 'exit-code'.
May 08 17:59:33 b4a37b483439 systemd[1]: open-balena-api.service: Main process exited, code=exited, status=1/FAILURE
May 08 17:59:33 b4a37b483439 api[982]:     at processTicksAndRejections (internal/process/task_queues.js:80:21)
May 08 17:59:33 b4a37b483439 api[982]:     at endReadableNT (internal/streams/readable.js:1327:12)
May 08 17:59:33 b4a37b483439 api[982]:     at IncomingMessage.EventEmitter.emit (domain.js:467:12)
May 08 17:59:33 b4a37b483439 api[982]:     at IncomingMessage.emit (events.js:327:22)
May 08 17:59:33 b4a37b483439 api[982]:     at Object.onceWrapper (events.js:421:28)
May 08 17:59:33 b4a37b483439 api[982]:     at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:1076:12)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.EventEmitter.emit (domain.js:467:12)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.emit (events.js:327:22)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1154:10)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.EventEmitter.emit (domain.js:467:12)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.emit (events.js:327:22)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.self.callback (/usr/src/app/node_modules/request/request.js:185:22)
May 08 17:59:33 b4a37b483439 api[982]:     at Request.handleResponse [as _callback] (/usr/src/app/src/features/contracts/contracts-directory.ts:123:3)
May 08 17:59:33 b4a37b483439 api[982]: Error: Invalid response while fetching contracts: Bad Gateway
May 08 17:59:33 b4a37b483439 api[982]:   ^
May 08 17:59:33 b4a37b483439 api[982]:                 new Error(
May 08 17:59:33 b4a37b483439 api[982]: /usr/src/app/src/features/contracts/contracts-directory.ts:123

@maggie0002, this looks to me (the missing resource) like a bug in openBalena. Something is expecting that resource to be there, and it is not. I’m checking to be sure. If so, I’ll open an issue and attach it.

@maggie0002, ok I have an idea what is happening. It seems that it is a minor bug in openBalena because a resource that the device wants is not present. However, improvements in device state handling that are in process right now will soon deprecate that resource anyway (at least as far as the device is concerned). So the error should eventually be going away with the latest Supervisor releases in a few months.

1 Like

Thanks for the update.

I’m aware Open Balena doesn’t currently have OS updates, but will supervisor updates still happen? In other words, will this bug/its related feature become deprecated on all existing devices or only new ones?

Hi there,
unfortunately there is still no easy way to update the OS or the supervisor in Open Balena, but you should be able to do it manually. I redirect you to an answer from another post that should explain this process: Roadmap for BalenaOS Updates in OpenBalena - #10 by pdcastro