feat: add command debug logging#64
Merged
Merged
Conversation
added 4 commits
July 11, 2026 10:42
Adds terse, grep-friendly debug logging so a live BLE-primary Router deployment can be diagnosed: which transport (bluetooth/fleet/teslemetry/tessie) served each command, and why it failed. Logging only, no behavior changes. - Commands._sendVehicleSecurity/_getVehicleSecurity/_sendInfotainment/_getInfotainment (commands.py) log command=<proto-derived name> transport=<t> result=..., covering both BLE and Fleet-signed commands from one choke point each. - TeslaFleetApi._request (fleet.py) logs the same shape for Fleet/Teslemetry/Tessie REST commands. - VehicleBluetooth's verify_commands timeout resolution logs a second line (verify_commands=resolved/unresolved). - Router._dispatch logs which backend served each call and any failover hop.
This was referenced Jul 11, 2026
Merged
Bre77
added a commit
that referenced
this pull request
Jul 12, 2026
* fix(fleet): guard _log_request_result against non-dict JSON bodies A JSON-legal response body that isn't a dict (null, list, or scalar - e.g. Teslemetry's list_authorized_clients returning null) crashed _request AFTER the HTTP request had already succeeded, since _log_request_result unconditionally called data.get() assuming a dict. It's DEBUG-level logging added purely for troubleshooting (#64) and must never break a successful request. * docs: note _log_request_result's non-dict body guard in AGENTS.md * no-mistakes(document): Document REST non-object responses --------- Co-authored-by: firstmate crewmate <crewmate@firstmate.local>
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.
Intent
Add DEBUG-level logging that records the result of every vehicle command and which transport served it (bluetooth vs Fleet API vs Teslemetry vs Tessie), so the captain can troubleshoot whether commands are going over Bluetooth during live HA-integration testing with a BLE-primary Router, and see why a command failed when it does.
Scope was deliberately logging-only: no behavior changes, no new exceptions, no timing changes, one issue per PR, no release cut.
Design decisions:
Verification performed: full pytest suite (218 tests incl. 9 new ones in tests/test_command_logging.py), ruff check/format, and pyright strict all pass on every touched file. Manually ran each of the three logging paths (BLE via mocked transport, REST via mocked aiohttp session, Router via fake backends) standalone with logging.basicConfig(DEBUG) to confirm the actual emitted log lines exactly match what's documented in docs/bluetooth_vehicles.md's new Troubleshooting section (including exact BluetoothTimeout message text).
Known pre-existing issue noted but NOT touched (out of scope): ruff format --check flags 5 files unrelated to this change (tesla_fleet_api/tesla/bluetooth.py, tesla_fleet_api/tesla/tesla.py, tesla_fleet_api/tesla/vehicle/vehicle.py, tesla_fleet_api/tessie/init.py, tests/test_tessie_vehicle_params.py) as needing reformatting - this is pre-existing drift on main, not introduced by this branch.
What Changed
verify_commandsresolution logging for timeout verification outcomes.Risk Assessment
✅ Low: The change is well-bounded to debug logging choke points and documentation/tests, with no material correctness, security, or behavior risks found in the reviewed diff.
Testing
Exercised the logging paths for BLE signed commands, verify_commands timeout resolution, Fleet REST, Teslemetry, Tessie, and Router failover; captured the actual DEBUG log lines as reviewer-visible evidence, then ran the full test suite successfully.
Evidence: DEBUG logging transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
tesla_fleet_api/tesla/fleet.py:195- REST requests logresult=successfor any successful JSON HTTP response, even when a vehicle command body is{"response": {"result": false, "reason": ...}}(for example rejected/no-op command responses). That makes the new grep-friendly command log disagree with the actual command outcome; consider mirroring the signed-command logger by extractingresponse.resultandresponse.reasonwhen present, and only using transport success for non-command response shapes.🔧 Fix: Log REST command body outcomes
1 warning still open:
tesla_fleet_api/tesla/fleet.py:37-_log_request_resultonly extracts command outcomes fromdata["response"], so Tessie command responses shaped like the existing Tessie vehicle tests'{"result": true}/{"result": false}fall through toresult=success. That preserves the same misleading log outcome for Tessie failures that the follow-up commit fixed for Fleet/Teslemetry-style wrapped responses; handle a top-levelresult/reasonshape before defaulting to transport success.🔧 Fix: Log Tessie command outcomes correctly
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
uv run pytest tests/test_command_logging.pyuv run python - <<'PY' > /tmp/no-mistakes-evidence/01KX7A2GCCPRYAFNJCQN64S56J/debug_logging_transcript.txt 2>&1uv run pytest tests✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.