Commit cc5cb4b
refactor: pass verify_ssl to remaining direct-Supervisor httpx callers (#1128)
* refactor: pass verify_ssl to remaining direct-Supervisor httpx callers
Closes #1127. Mirrors the verify=self.verify_ssl propagation pattern
established in #1126 (rest_client.py:_get_addon_logs_via_supervisor) at
the two other direct-Supervisor httpx call sites:
- tools_bug_report.py:_fetch_addon_logs uses get_global_settings().verify_ssl
(module-level helper, no self/closure context).
- settings_ui.py:_restart_addon uses server.client.verify_ssl (closure has
access to server: HomeAssistantSmartMCPServer).
Both paths effectively propagate Settings.verify_ssl via the access route
appropriate to each call site's scope. The http://supervisor URL is plain
HTTP and TLS-irrelevant in practice — the parameter keeps all three
constructor sites consistent with the established HomeAssistantClient
pattern.
* refactor: read verify_ssl from server.settings instead of server.client
Per Gemini review on PR #1128: server.client is a lazy @Property
(server.py) — accessing it for a single config bool would instantiate
the full HomeAssistantClient (httpx pool, settings re-read, log line)
on first access. server.settings is eager-initialized in the
HomeAssistantSmartMCPServer constructor and is the canonical source of
truth for verify_ssl.
Additional benefit: in OAuth deployment mode (__main__.py:868),
HomeAssistantSmartMCPServer is constructed with an OAuthProxyClient
whose __getattr__ proxies to a per-request OAuth client requiring an
authenticated request context. _restart_addon is a plain admin POST
without that context, so server.client.verify_ssl could have surfaced
as an auth error in OAuth mode. server.settings.verify_ssl sidesteps it
without depending on OAuthProxyClient's attribute-forwarding semantics.
* test: pin _restart_addon untested branches per Boy-Scout
Adds unit-test coverage for the two previously-untested branches in
settings_ui.py:_restart_addon:
- Missing SUPERVISOR_TOKEN (settings_ui.py:780-789) — non-addon installs
hit this when the user clicks Restart against a Docker/pyinstaller
setup; the structured 400 must surface rather than ever reaching the
Supervisor URL.
- Connection-drop-as-success (settings_ui.py:798-801) — the Supervisor
kills our process mid-request during a restart, so a ReadError /
RemoteProtocolError / ConnectError from the POST is the documented
success signal.
Mirrors the _capture_handler pattern from TestSaveToolsValidation. The
fixture-level server.settings.verify_ssl = True is required by this
PR's post-G1 access path (httpx accepts only bool/SSLContext for verify=).
Boy-Scout fix while already touching _restart_addon for the
verify_ssl-propagation refactor — closes the test-coverage gap I'd
flagged in #960's approve-body but never followed up on at the time.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 13412aa commit cc5cb4b
3 files changed
Lines changed: 233 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
265 | 268 | | |
266 | 269 | | |
267 | 270 | | |
| |||
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
302 | 307 | | |
303 | 308 | | |
304 | 309 | | |
| |||
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
365 | | - | |
| 370 | + | |
| 371 | + | |
366 | 372 | | |
367 | 373 | | |
368 | 374 | | |
| |||
525 | 531 | | |
526 | 532 | | |
527 | 533 | | |
528 | | - | |
529 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
530 | 540 | | |
531 | 541 | | |
532 | 542 | | |
| |||
763 | 773 | | |
764 | 774 | | |
765 | 775 | | |
| 776 | + | |
766 | 777 | | |
767 | 778 | | |
768 | 779 | | |
| |||
868 | 879 | | |
869 | 880 | | |
870 | 881 | | |
871 | | - | |
| 882 | + | |
| 883 | + | |
872 | 884 | | |
873 | 885 | | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
880 | 894 | | |
881 | 895 | | |
882 | 896 | | |
| |||
892 | 906 | | |
893 | 907 | | |
894 | 908 | | |
895 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
896 | 912 | | |
897 | 913 | | |
898 | 914 | | |
899 | 915 | | |
900 | | - | |
901 | | - | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
902 | 923 | | |
903 | 924 | | |
904 | 925 | | |
| |||
924 | 945 | | |
925 | 946 | | |
926 | 947 | | |
927 | | - | |
928 | | - | |
929 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
930 | 953 | | |
931 | 954 | | |
932 | 955 | | |
| |||
958 | 981 | | |
959 | 982 | | |
960 | 983 | | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
184 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 201 | + | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
| |||
256 | 255 | | |
257 | 256 | | |
258 | 257 | | |
259 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| |||
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
0 commit comments