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 mqtt config validation error handling #103210

Merged
merged 5 commits into from
Nov 2, 2023
Merged

Fix mqtt config validation error handling #103210

merged 5 commits into from
Nov 2, 2023

Conversation

jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Nov 1, 2023

Proposed change

When an invalid yaml config is found, this no longer fails mqtt starting up. This PR fixes some cases where processing an invalid config, and fails logging a correct error message.

This PR fixes correct logging an invalid config in case:

  • A ValueError was raised during config validation, causing not to log the by the caller intended error message.
  • A YAML config contains mappings or lists causing the generation of the YAML config in the issue reported contain unwanted diagnostic information. And caused failing generating a hash over the config to be used as issue ID.
  • A config with an invalid entity_category for sensor or binary_sensor was used in a configuration. These validation issues were caused by Add check that sensors don't have EntityCategory.CONFIG set #101471

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Nov 1, 2023

Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration (mqtt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mqtt can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign mqtt Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@jbouwh jbouwh added this to the 2023.11.1 milestone Nov 1, 2023
@jbouwh jbouwh force-pushed the fix-mqtt-config-check branch from 37efe11 to 69b0ee4 Compare November 2, 2023 07:14
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @jbouwh

@jbouwh jbouwh merged commit 4a4d2ad into dev Nov 2, 2023
53 checks passed
@jbouwh jbouwh deleted the fix-mqtt-config-check branch November 2, 2023 09:57
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
@elupus
Copy link
Contributor

elupus commented Nov 5, 2023

This broke mqtt: #103414 this extended the config entity check to binary sensors, which have not been fixed upstream in mqtt.

@jbouwh
Copy link
Contributor Author

jbouwh commented Nov 5, 2023

It did not, #101471 is effectively the cause. #103414 was just to make sure a proper error message was raised.

@elupus
Copy link
Contributor

elupus commented Nov 5, 2023

#101471 does not check binary_senors domain (to be complete it probably should). But for mqtt a check was added here for binary sensors.

@jbouwh
Copy link
Contributor Author

jbouwh commented Nov 5, 2023

Right, did not realize that. To be consequent we should handle binary_sensor in the same way

@jbouwh
Copy link
Contributor Author

jbouwh commented Nov 5, 2023

May be we should just allow the setting for a couple of months and raise an issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entity sensor XXX cannot be added as the entity category is set to config
4 participants