alandtse / alandtse/tesla

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

Ouverte
#1,173 5 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
stale triage
Langage dominant
Python
Étoiles
780
Forks
127
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## 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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.