Handle recreated repository IDs - #5463
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request addresses a startup edge case where the local stored repository registry (.storage/hacs.repositories) can contain multiple GitHub repository IDs for the same repository slug (e.g., after a repo is deleted/recreated), which previously could lead to “duplicate IDs” warnings and later failures when merging with the live catalog.
Changes:
- Add repository-ID reconciliation logic to merge same-slug repository entries into a single registry object while preserving installed/default state.
- Adjust restore/registration flow to prefer restoring by stored ID first to avoid cross-applying data between same-slug entries.
- Add targeted tests covering stale-ID reconciliation and rejection of ID collisions across different slugs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
custom_components/hacs/base.py |
Adds reconcile_repository_id() to consolidate duplicate same-slug repositories and remap to the live catalog ID while preserving state. |
custom_components/hacs/utils/data.py |
Updates restore/unknown-registration flow to support reconciliation and avoid duplicate-ID warnings during restore. |
tests/hacsbase/test_hacsbase_data.py |
Adds regression tests for stale ID reconciliation and for rejecting ID reuse across different slugs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replace stale stored IDs with the catalog ID while keeping repository state.
eaf5512 to
6001d64
Compare
|
I reproduced CI locally against
The missing API-usage snapshots are included. Could a maintainer approve the workflows and add |
|
@ludeeus could you please have a look? |
Summary
GitHub assigns a new ID when a repository is deleted and recreated. HACS kept the stored ID and failed while loading the catalog.
Use the catalog ID for the same repository name, keep installed/default state, and remove the stale ID on the next store write. IDs already assigned to another repository still raise an error.
Tests
Added coverage for restore order, persistence and restart, removed and archived repositories, repeated ID changes, and ID collisions. A 1,000-entry catalog test checks that unchanged entries do not run reconciliation.
Fixes #5461