Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation does not support deeply nested objects #2560

Closed
mKeRix opened this issue Feb 10, 2021 · 4 comments
Closed

Validation does not support deeply nested objects #2560

mKeRix opened this issue Feb 10, 2021 · 4 comments

Comments

@mKeRix
Copy link

mKeRix commented Feb 10, 2021

Describe the issue you are experiencing

After the recent schema change I talked to frenck on Discord, who suggested that the nested depth limitation in the docs isn't an actual limitation and just a recommendation. I tried writing a schema for this and was met with errors. Take this sample schema:

{
  "logger": {
    "elasticsearch": {
      "enabled": "bool?",
      "node": "str?",
      "auth": {
        "username": "str?",
        "password": "str?",
        "apiKey": "str?"
      },
      "indexPrefix": "str?"
    }
  }
}

Adding this into an add-on will cause it to fail to load (see supervisor logs below). The same happens for nested arrays, e.g.:

{
  "gpio": {
    "binarySensors": [
      {
        "name": "str"
      }
    ]
  }
}

I would expect any level of nesting to work, especially since there are no other options left for configuration.

What is the used version of the Supervisor?

supervisor-2021.02.6

What type of installation are you running?

Home Assistant Supervised

Which operating system are you running on?

Debian

What is the version of your installed operating system?

9.13

What version of Home Assistant Core is installed?

core-2021.2.1

Steps to reproduce the issue

  1. Create a local add-on and configure the schema as shown above. You can use the room-assistant add-on as template.
  2. Hit the reload button in the add-on store.
  3. Observe the add-on not being loaded and warnings in the logs.
    ...

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

# Log for nested objects
21-02-10 19:46:27 WARNING (MainThread) [supervisor.store.data] Can't read /data/addons/local/room_assistant/config.json: expected string or buffer for dictionary value @ data['schema']['logger']['elasticsearch']. Got {'enabled': 'bool?', 'node': 'str?', 'auth': {'username': 'str?', 'password': 'str?', 'apiKey': 'str?'}, 'indexPrefix': 'str?'}

# Log for nested array
21-02-10 20:58:12 WARNING (MainThread) [supervisor.store.data] Can't read /data/addons/local/room_assistant/config.json: expected string or buffer @ data['schema']['gpio']['binarySensors'][0]. Got {'name': 'str'}

This issue is aftermath of #2540, more info for this specific add-on can be found at mKeRix/room-assistant#501. This problem is preventing me from restoring the same functionality that my add-on had before the schema change.

@Poeschl
Copy link

Poeschl commented Feb 11, 2021

Can confirm that the depth limit of 2 exists since last year. I rewrote my json configs with jq to be able to get all settings for a addon (Poeschl/Hassio-Addons@ccfd9e6).

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@Wh1terat
Copy link

Wh1terat commented May 5, 2021

  "options": {
    "tunnels": [],
    "log_level": "info"
  },
  "schema": {
    "tunnels": [
      {
        "enabled":"bool",
        "credentials": {
          "AccountTag":"str",
          "TunnelSecret": "str",
          "TunnelID":"str",
          "TunnelName": "str"
        },
        "ingress": [
          {
            "hostname":"str?",
            "service":"str?",
            "path":"str?"
          }
        ]
      }
    ],
    "log_level": "list(trace|debug|info|warn|error|fatal|panic)"
  }

Argh. Just written my first addon and found this exact issue with regard to deep nesting. (which lets be fair, in the grand scheme of things is hardly "deep").

Should really be fixed; the limitation feels unnatural and unnecessary.
I'm loathed to flatten everything, move to blobs - or standalone config files mapped over.

@casperklein
Copy link
Contributor

You should open a new issue. Closed issues are not recognized in my experience.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants