Hassio-Addons icon indicating copy to clipboard operation
Hassio-Addons copied to clipboard

[git-exporter] jq: error (at <stdin>:1): Cannot iterate over null (null)

Open bjeanes opened this issue 3 years ago • 1 comments

Which addon? git-exporter

Describe the bug It no longer runs due to failing to get add-ons:

Screen Shot 2022-07-19 at 5 06 01 pm

To Reproduce

Unclear, it may be a HA version thing. I have fiddled around a bit and deduced that based on https://github.com/Poeschl/Hassio-Addons/blob/0e0cd58135754f7fdddbb29431b07d766af6f63e/git-exporter/root/run.sh#L142 ... the /addons call used to have a top-level "repositories" key.

On HA 2022.7, this appears not to be the case (not sure when it broke).

[core-ssh ~]$ bashio::api.supervisor GET "/addons" false | jq -C 'keys'
[
  "addons"
]

Based on https://developers.home-assistant.io/docs/api/supervisor/endpoints/, it seems like it should be using /store/repositories instead:

[core-ssh ~]$ bashio::api.supervisor GET "/store/repositories" false | jq -C '.[]|keys[]'|sort -u
"maintainer"
"name"
"slug"
"source"
"url"

System

  • Home Assistant 2022.7.5
  • Supervisor 2022.07.0
  • Operating System 8.2
  • Frontend 20220707.1

bjeanes avatar Jul 19 '22 08:07 bjeanes

Waiting for an answer on https://github.com/hassio-addons/bashio/issues/111 for this.

Poeschl avatar Jul 27 '22 15:07 Poeschl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 12 '22 00:08 stale[bot]

Will be fixed with the next merge from dev. Sch bot

Poeschl avatar Aug 12 '22 05:08 Poeschl

Hmm, not sure if there have been other changes besides this but today was the first time I ran the exporter since it stopped working, and I was surprised to see it deleted all addon configuration:

[main 715aeff] Home Assistant Git Exporter
 38 files changed, 1046 insertions(+), 403 deletions(-)
 delete mode 100644 addons/243ffc37_git-exporter.yaml
 delete mode 100644 addons/243ffc37_rsync.yaml
 delete mode 100644 addons/243ffc37_syncthing.yaml
 delete mode 100644 addons/45df7312_zigbee2mqtt.yaml
 delete mode 100644 addons/77b2833f_timescaledb.yaml
 delete mode 100644 addons/9c51689a_pgweb.yaml
 delete mode 100644 addons/a0d7b954_esphome.yaml
 delete mode 100644 addons/a0d7b954_nodered.yaml
 delete mode 100644 addons/a0d7b954_zerotier.yaml
 delete mode 100644 addons/cebe7a76_hassio_google_drive_backup.yaml
 delete mode 100644 addons/core_configurator.yaml
 delete mode 100644 addons/core_mosquitto.yaml
 delete mode 100644 addons/core_samba.yaml
 delete mode 100644 addons/core_ssh.yaml

@Poeschl was that intentional?

bjeanes avatar Aug 24 '22 03:08 bjeanes

The retrieval of the addon config changed. That shouldn't delete all configs. Are they added again?

Poeschl avatar Aug 24 '22 04:08 Poeschl

They are not. They just don't export anymore.

The only thing in the addons dir is the repositories.yaml - https://git.bjeanes.com/bo/ha-config/src/branch/main/addons

bjeanes avatar Aug 24 '22 04:08 bjeanes

Do you find any log output from this line bashio::log.info "Get ${addon} configs" on your last run?

If not the addons api have changed also.

Poeschl avatar Aug 24 '22 04:08 Poeschl

That line doesn't even show up, even though I have addons: true in configuration:

[14:25:01] INFO: Start git export
[14:25:01] INFO: Pull latest
From https://git.bjeanes.com/bo/ha-config
   715aeff..8d3df54  main       -> origin/main
HEAD is now at 8d3df54 Ignore solcast forecast file
[14:25:02] INFO: Get Home Assistant config
[14:25:02] INFO: Get Lovelace config yaml
[14:25:03] INFO: Get ESPHome configs
[14:25:04] INFO: Get addon repositories
[14:25:04] INFO: Get Node-RED flows
[14:25:05] INFO: Add secrets pattern
[14:25:05] INFO: Add secrets from secrets.yaml
[14:25:05] INFO: Prohibited patterns:
password:\s?[\'"]?\w+[\'"]?\n?
token:\s?[\'"]?\w+[\'"]?\n?
client_id:\s?[\'"]?\w+[\'"]?\n?
api_key:\s?[\'"]?\w+[\'"]?\n?
chat_id:\s?[\'"]?\w+[\'"]?\n?
allowed_chat_ids:\s?[\'"]?\w+[\'"]?\n?
latitude:\s?[\'"]?\w+[\'"]?\n?
longitude:\s?[\'"]?\w+[\'"]?\n?
credential_secret:\s?[\'"]?\w+[\'"]?\n?
[14:25:05] INFO: Checking for secrets
[14:25:06] INFO: Commit changes and push to remote
[main 8f1ebd0] Home Assistant Git Exporter
 2 files changed, 4 insertions(+), 3 deletions(-)
remote: . Processing 1 references        
remote: Processed 1 references in total        
To https://git.bjeanes.com/bo/ha-config.git
   8d3df54..8f1ebd0  main -> main
[14:25:15] INFO: Exporter finished

bjeanes avatar Aug 24 '22 04:08 bjeanes

Seems that we have a new issue then 😅

The return of the addons does not return any installed addons or has changed. 😐

Poeschl avatar Aug 24 '22 04:08 Poeschl

I tested this in Terminal add-on.

I have this helper to experiment with bashio commands interactively:

function bashio() {
  # load bashio, then unset flags which cause it to exit on any failure
  bash --init-file <(echo "source /usr/lib/bashio/bashio.sh; set +o errexit; set +o errtrace; set +o nounset; set +o pipefail")
}

Here:

~ $ bashio::addons.installed # no output
~ $ bashio::addons | jq '.addons | length'
23
~ $ bashio::addons | jq '.addons[0]'
{
  "name": "Samba share",
  "slug": "core_samba",
  "description": "Expose Home Assistant folders with SMB/CIFS",
  "advanced": false,
  "stage": "stable",
  "version": "10.0.0",
  "version_latest": "10.0.0",
  "update_available": false,
  "available": true,
  "detached": false,
  "homeassistant": null,
  "state": "started",
  "repository": "core",
  "build": false,
  "url": "https://github.com/home-assistant/hassio-addons/tree/master/samba",
  "icon": true,
  "logo": true
}
~ $ bashio::addons.installed core_samba
true

It looks like you are already iterating over the addons to check if installed https://github.com/Poeschl/Hassio-Addons/blob/f67bb090029561153d8b40a541d9f6fb3111b5a2/git-exporter/root/run.sh#L133-L134

So in principle, just removing .installed here should fix the issue https://github.com/Poeschl/Hassio-Addons/blob/f67bb090029561153d8b40a541d9f6fb3111b5a2/git-exporter/root/run.sh#L131

WDYT?

bjeanes avatar Aug 24 '22 05:08 bjeanes