Commit 4463d7d
committed
fix: address KP13 CR — role bump, fail-fast token, system_service source
Critical (review items 1-4):
- Empty SUPERVISOR_TOKEN now fail-fast HomeAssistantAuthError with distinct
message ("absent at call time"), so detection/config mismatches don't
read as "token rejected" (item 1).
- 403 carved out as distinct branch with role-hint suggestion + warning log
before raise — most-likely cause for homeassistant-ai#1116-class failures is now hassio_role
too low (item 2).
- _get_supervisor_log docstring updated to describe the branch-on-
is_running_in_addon() behavior, drop homeassistant-ai#950-only framing (item 3).
- _get_addon_logs_via_supervisor docstring rewritten to enumerate
scope/role differences vs _fetch_addon_logs instead of claiming mirror (item 4).
Important (items 5-9):
- verify=self.verify_ssl kept with explicit symmetry comment citing homeassistant-ai#1128's
three-site convention (item 5, KP13's option B).
- Supervisor's {"result":"error","message":"..."} JSON envelope now parsed
before the raw-text fallback (item 6).
- Distinct timeout vs transport error messages (item 7).
- logger.warning fires before every 4xx raise so operators see status+path
without enabling debug (item 9).
Test gaps (items 10-15):
- New: test_raises_auth_error_on_empty_supervisor_token (item 10).
- New: test_raises_connection_error_on_remote_protocol_error (item 11).
- New: test_empty_body_no_reason_phrase_uses_placeholder for tier-3 fallback
parity with the proxy branch (item 12).
- ctor-kwargs (verify + timeout) asserted on the URL+auth happy path so a
regression that hard-codes either keeps CI red (item 13).
- TestGetAddonLogsBranchSelection::test_addon_install_uses_supervisor_direct
shrunk to gate-only — URL/auth contract delegated to dedicated class (item 14).
- patch path migrated from "ha_mcp.client.rest_client.httpx.AsyncClient" to
"httpx.AsyncClient" — robust to both \`import httpx\` and a future
\`from httpx import AsyncClient\` (item 15).
Comment trims (items 16-17):
- get_addon_logs docstring gate description corrected to is_running_in_addon()
rather than "SUPERVISOR_TOKEN env present" (item 16).
- Per-test/fixture/class-level redundant narration trimmed (item 17).
Decline:
- Item 8 (level applies to source="supervisor"): warning is already emitted
at tools_utility.py:139 — \`supervisor\` is in the level-not-applicable
warning tuple, pinned by test_level_param_emits_warning_for_supervisor_source.
This PR adds \`system_service\` to the same tuple plus a parallel test for
parity.
Scope additions per KP13's PR-comment 12:42:
- hassio_role: default → manager in both addon config.yamls, with comment
citing the live test result.
- New source="system_service" with slug enum {supervisor, host, core, dns,
audio, multicast, observer}. Hits http://supervisor/<service>/logs via the
same direct-Supervisor pattern (extracted to shared _supervisor_logs_get
helper). Caller-layer slug-enum validation gives users the allowed-set
before the request fires.1 parent 9e6c012 commit 4463d7d
5 files changed
Lines changed: 686 additions & 103 deletions
File tree
- homeassistant-addon-dev
- homeassistant-addon
- src/ha_mcp
- client
- tools
- tests/src/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
442 | | - | |
443 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
| |||
452 | 453 | | |
453 | 454 | | |
454 | 455 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
459 | 462 | | |
460 | 463 | | |
461 | 464 | | |
| |||
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
472 | | - | |
473 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
474 | 483 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
480 | 499 | | |
481 | 500 | | |
482 | | - | |
483 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
484 | 513 | | |
485 | 514 | | |
486 | 515 | | |
487 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
488 | 520 | | |
489 | 521 | | |
490 | 522 | | |
| |||
496 | 528 | | |
497 | 529 | | |
498 | 530 | | |
499 | | - | |
| 531 | + | |
500 | 532 | | |
501 | 533 | | |
502 | 534 | | |
503 | | - | |
| 535 | + | |
504 | 536 | | |
505 | 537 | | |
506 | 538 | | |
507 | 539 | | |
508 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
509 | 557 | | |
510 | 558 | | |
511 | 559 | | |
512 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
513 | 581 | | |
514 | 582 | | |
515 | 583 | | |
516 | | - | |
| 584 | + | |
517 | 585 | | |
518 | 586 | | |
519 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
520 | 617 | | |
521 | 618 | | |
522 | 619 | | |
| |||
0 commit comments