home-assistant / supervisor

:house_with_garden: Home Assistant Supervisor
https://home-assistant.io/hassio/
Apache License 2.0
1.73k stars 633 forks source link

Correctly parsed YAML config can cause addon to not show up #4967

Closed Erudition closed 5 months ago

Erudition commented 6 months ago

Describe the issue you are experiencing

This issue is moved from https://github.com/home-assistant/core/issues/112571

It took me a while to track down why my addon was dissappearing from my repository, as seen by Home Assistant. The issue was a schema line like this: processed_recording_folder: 'match(^(([a-zA-Z0-9-_]+)+|))$' I accidentally put the $ outside the match() parens.

However, versions with this issue would simply not appear in Home Assistant. If it was already installed, it would not find an update and the icon image would break.

What type of installation are you running?

Home Assistant OS

Which operating system are you running on?

Home Assistant Operating System

Steps to reproduce the issue

Try an addon with config such as

schema:
  processed_recording_folder: 'match(^(([a-zA-Z0-9-_]+)+|)$)'
  output_segment_size: int
  max_folder_size_megabytes: int(100,10000000)
  max_overall_disk_usage_percent: int(50,99)
  should_rerun: bool
  sleep_duration: 'match(^(\\d*\\.?\\d+)d|\\s+|(\\d*\\.?\\d+)h|\\s+|(\\d*\\.?\\d+)m|\\s+|(\\d*\\.?\\d+)s|\\s+|(\\d*\\.?\\d+))$'

Anything in the Supervisor logs that might be useful for us?

No. I wish!

System Health information

System Information

version core-2024.3.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.20-haos
arch aarch64
timezone America/Chicago
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1402 Downloaded Repositories | 11
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.03.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 28.0 GB disk_used | 19.9 GB healthy | true supported | true board | green supervisor_api | ok version_api | ok installed_addons | Studio Code Server (5.15.0), Whisper (2.0.0), Log Viewer (0.17.0), AirCast (4.2.1), Advanced SSH & Web Terminal (17.2.0), Mosquitto broker (6.4.0), Fusion (2024.2.1), Assist Microphone (1.2.0), openWakeWord (1.10.0), Piper (1.5.0), File editor (5.8.0), Samba share (12.3.1), VLC (0.3.0), FTP (5.0.1), Grafana (9.2.0), motionEye (0.20.0), Tailscale (0.16.1), Tidy Recordings (1.98), Music Assistant BETA (2.0.0b116), Rclone Backup (3.1.0), oobabooga-text-generation-webui (2024.03.03)
Dashboards dashboards | 3 -- | -- resources | 2 views | 3 mode | storage
Recorder oldest_recorder_run | March 14, 2024 at 6:39 AM -- | -- current_recorder_run | March 19, 2024 at 12:03 AM estimated_db_size | 71.95 MiB database_engine | sqlite database_version | 3.44.2

Supervisor diagnostics

No response

Additional information

No response

mdegat01 commented 5 months ago

I just made a dummy addon and dropped your exact schema in. And then I refreshed my addon store. As you described, my addon does not appear. However when I look at the supervisor logs, I see this:

2024-03-27 11:47:05.823 WARNING (SyncWorker_7) [supervisor.store.data] Can't read /data/addons/local/example/config.yaml: does not match regular expression ^(?:|bool|email|url|port|device(?:\((?P<filter>subsystem=[a-z]+)\))?|str(?:\((?P<s_min>\d+)?,(?P<s_max>\d+)?\))?|password(?:\((?P<p_min>\d+)?,(?P<p_max>\d+)?\))?|int(?:\((?P<i_min>\d+)?,(?P<i_max>\d+)?\))?|float(?:\((?P<f_min>[\d\.]+)?,(?P<f_max>[\d\.]+)?\))?|match\((?P<match>.*)\)|list\((?P<list>.+)\))\??$ for dictionary value @ data['schema']['sleep_duration']. Got 'match(^(\\\\d*\\\\.?\\\\d+)d|\\\\s+|(\\\\d*\\\\.?\\\\d+)h|\\\\s+|(\\\\d*\\\\.?\\\\d+)m|\\\\s+|(\\\\d*\\\\.?\\\\d+)s|\\\\s+|(\\\\d*\\\\.?\\\\d+))$'

This tells me that my addons config is invalid, which it is. Seems like its working correctly here.

Are you looking at the supervisor logs or the core logs? If you go to the logs page it only shows you core logs. You have to change the dropdown at the top to "supervisor" to see the supervisor logs.

Erudition commented 5 months ago

Yikes, that's quite buried. I did not know I have to keep an eye on the supervisor logs as well.

Thanks for confirming.

Anyway, the only error in this example is a single value in a single field, and the YAML itself is parseable and free of sytnax errors, so it seems we can do better than silently dropping the whole addon.

But yeah, the message in the logs is better than nothing!

agners commented 5 months ago

Yikes, that's quite buried. I did not know I have to keep an eye on the supervisor logs as well.

The Supervisor is really the component/software which handles add-ons. Maybe this is not quite obvious/clear to an add-on developers :thinking: If you have a suggestion where to add a hint (e.g. in the add-on developer docs maybe?), please, let me know (or create a PR directly at https://github.com/home-assistant/developers.home-assistant).

Anyway, the only error in this example is a single value in a single field, and the YAML itself is parseable and free of sytnax errors, so it seems we can do better than silently dropping the whole add-on.

In the end, that is how the parsing and validation logic works: Validate, if any error appears, go safe and skip the add-on. As add-on updates are done in the background, we can't really show this in the frontend.

I am closing this here as this is currently how things are intended to work.