Repository navigation
Normalise settings on a fresh install (Vehicles page and VIN check crash without settings.json) - #758
Open
MikeBishop wants to merge 2 commits into
Open
MikeBishop wants to merge 2 commits into
MikeBishop wants to merge 2 commits into
Conversation
loadSettings returned early when settings.json did not exist, skipping everything after the file read: the built-in Allow/Deny Charging vehicle groups, the sunrise/sunset bridge values, the registry/held-limit/budget loads, token restore, and module updateSettings. Without VehicleGroups, the Vehicles page raised UndefinedError and checkVINEntitlement raised KeyError as soon as a car reported a VIN. Both have depended on that key since v1.2.2 (790c590, 5c737e2); the early return dates to the settings.json format itself (da3a8d4). The condition clears on the first restart after settings.json is written. A missing file now falls through as an empty dict, so a fresh install gets exactly the settings an empty settings.json would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a fresh install with no
settings.jsonyet,TWCMaster.loadSettings()fills in the defaults and then returns early. Everything after the file read gets skipped, including creating the built-inAllow Charging/Deny Chargingvehicle groups. Two things depend on those groups existing:vehicles.html.j2loops overmaster.settings["VehicleGroups"].keys(), and the page fails withjinja2.exceptions.UndefinedError: 'dict object' has no attribute 'VehicleGroups'.checkVINEntitlement()readsself.settings["VehicleGroups"][...]directly and raisesKeyErroras soon as a TWC reports a VIN. This happens even in the default authorization mode (1).The early return also skips the vehicle registry, held-limit, watch-budget and fleet-spend loads, token restore, the sunrise/sunset defaults, and each vehicle module's
updateSettings().The problem clears on the first restart after
settings.jsonhas been written, because loading an existing file does create the groups. That's probably why it has gone unnoticed.How far back
settings.jsonwas introduced (da3a8d4, Oct 2019). It was harmless until code started relying on the groups.main, is affected.Fix
A missing settings file is now treated as an empty settings dict and goes through the same steps as a loaded file. A fresh install ends up with exactly the settings an empty
settings.jsonwould give.Tests
New
tests/unit/test_fresh_install_settings.py, run with nosettings.json:settings.jsoncheckVINEntitlement()returns 1 instead of raisingAll four fail on current
mainand pass with this change. The full unit suite passes (2660 tests).🤖 Generated with Claude Code