[config] Early termination of validation steps on error - #6837
Conversation
|
Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration ( |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6837 +/- ##
==========================================
+ Coverage 53.70% 53.90% +0.19%
==========================================
Files 50 50
Lines 9408 9623 +215
Branches 1654 1698 +44
==========================================
+ Hits 5053 5187 +134
- Misses 4056 4112 +56
- Partials 299 324 +25 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Would this not apply to all platforms? They all have this function call at the bottom
You would think so, but with esp32 a bad key is reported as expected, but not on host. It would make sense to move all of them to the top, I just didn't want to make unnecessary changes. |
So the ESP32 and ESP8266 and probably the others can't have the validation function first, since those functions use data provided in the config, like the framework and board. I'm still not 100% sure why there is a difference, but I think I got closer to the root cause - when executing a sequence of validation steps, an error in any step should terminate the process, since subsequent validations may depend on successful earlier ones. Code updated accordingly. See what you think. |
What does this implement/fix?
If the host: platform is used, and an invalid key is specified in the config for it, the platform never gets set and there is a subsequent exception thrown.
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: