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

Fix error if a custom_sentences file is empty #93530

Merged
merged 4 commits into from
May 30, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions homeassistant/components/conversation/default_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,20 @@ def _get_or_load_intents(
encoding="utf-8"
) as custom_sentences_file:
# Merge custom sentences
merge_dict(
intents_dict, yaml.safe_load(custom_sentences_file)
)
if isinstance(
custom_sentences_yaml := yaml.safe_load(
custom_sentences_file
),
dict,
):
merge_dict(intents_dict, custom_sentences_yaml)
else:
_LOGGER.warning(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea to not leave the user in total darkness if something's up with his files

"Could not load custom sentences file language=%s (%s), path=%s",
tetele marked this conversation as resolved.
Show resolved Hide resolved
language,
language_variation,
custom_sentences_file.name,
)

# Will need to recreate graph
intents_changed = True
Expand Down