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 all 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
15 changes: 12 additions & 3 deletions homeassistant/components/conversation/default_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,18 @@
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

Check warning on line 424 in homeassistant/components/conversation/default_agent.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/conversation/default_agent.py#L424

Added line #L424 was not covered by tests
),
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

"Custom sentences file does not match expected format path=%s",
custom_sentences_file.name,
)

# Will need to recreate graph
intents_changed = True
Expand Down