alandtse / alandtse/tesla

Python 3.13 compatibility: KeyError 'home-page' in authcaptureproxy breaks import

Đang mở
#1,173 5 bình luận 2 reaction 0 người được giao Xem trên GitHub
stale triage
Ngôn ngữ chính
Python
Star
780
Fork
127
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Context
After updating Home Assistant to a version that runs on **Python 3.13**, the custom integrations **alexa_media** and **tesla_custom** fail to load due to an import-time exception in a shared dependency: **authcaptureproxy**.

This appears to be caused by stricter/different package metadata handling in Python 3.13 (via `importlib_metadata`). `authcaptureproxy` reads the distribution metadata and directly indexes the key `home-page`, which raises a `KeyError` when that field is missing.

## What happens
Home Assistant fails to import the integration stack because `authcaptureproxy` crashes at import time.

- **Error type:** `ImportError` caused by `KeyError: 'home-page'`
- **Affected file:** `/usr/local/lib/python3.13/site-packages/authcaptureproxy/__init__.py`
- **Line:** 31
- **Failing line:** `__uri__ = metadata["home-page"]`

## Traceback (excerpt)
```text
Python File "/usr/local/lib/python3.13/site-packages/alexapy/alexaproxy.py", line 15, in
import authcaptureproxy

File "/usr/local/lib/python3.13/site-packages/authcaptureproxy/__init__.py", line 31, in
__uri__ = metadata["home-page"]
~~~~~~~~^^^^^^^^^^^^^

File "/usr/local/lib/python3.13/site-packages/importlib_metadata/_adapters.py", line 102, in __getitem__
raise KeyError(item)

KeyError: 'home-page'
```

## Expected behavior
The integration should load on Python 3.13.

## Suggested fix
Make the metadata access in `authcaptureproxy/__init__.py` more robust, e.g.:

- Use a safe accessor: `metadata.get("home-page")` (or `metadata.get("Home-page")` depending on normalization)
- Fall back to other common fields such as `project-url` / `Project-URL` or `homepage` if present
- Or wrap in `try/except KeyError` and default `__uri__` to `None`/empty string

This would avoid a hard import-time crash when the metadata field is absent.

## Notes
This regression started immediately after moving to a Home Assistant release that uses **Python 3.13**, and affects multiple custom integrations because they share the same dependency.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.