inventory: extra type validations in combining dicts and parsing script json

- avoids a stacktrace when trying to combine vars that are not both dictionaries, and returns a proper error
- detects wrong variable types in the InventoryScript json

fixes #8704