Skip to content

Use authenticated brands proxy for update entity pictures#5228

Open
manuveli wants to merge 1 commit intohacs:mainfrom
manuveli:fix/brands-proxy-update-entity-picture
Open

Use authenticated brands proxy for update entity pictures#5228
manuveli wants to merge 1 commit intohacs:mainfrom
manuveli:fix/brands-proxy-update-entity-picture

Conversation

@manuveli
Copy link
Copy Markdown

Summary

HacsRepositoryUpdateEntity.entity_picture returned a hardcoded legacy-CDN URL:

return f"https://brands.home-assistant.io/_/{self.repository.data.domain}/icon.png"

After the brands-proxy API landed in HA 2026.3, the CDN no longer accepts new custom-integration submissions, so Update entities for custom integrations that ship inline brand/ assets show a broken picture.

Change

Return /api/brands/integration/{domain}/icon.png — a relative path served by HA's local brands proxy. For core integrations the proxy fetches the upstream CDN image via stale-while-revalidate; for custom integrations it serves the inline brand/icon.png bundled with the integration.

Snapshots under tests/snapshots/hacs-test-org/ were regenerated via pytest --snapshot-update. The domains.json references in custom_components/hacs/validate/brands.py and its fixtures are intentionally untouched — that validator's fallback still serves a valid back-compat check for custom integrations already present in the brands repo.

Relates to #5171
Relates to #5223

The primary fix for the HACS dashboard icons lives in hacs/frontend; this PR finishes the job for Update entities.

Open question for reviewers

This change assumes the HA frontend's entity-picture rendering pipeline applies addBrandsAuth (from upstream src/util/brands-url.ts) to URLs beginning with /api/brands/, so that the access token gets appended client-side. If that's not the case for the update-card render path, the path will 401 on HA ≥ 2026.3. Please verify — happy to pivot if a different shape of URL is preferred.

Test plan

  • scripts/test passes (pytest with refreshed snapshots).
  • ruff check passes.
  • Against HA ≥ 2026.3 with HACS installed and a custom integration shipping inline brand assets: the HACS Update entity for that integration shows the correct logo; network inspector shows a request to /api/brands/integration/{domain}/icon.png?token=….

🤖 Generated with Claude Code

The `entity_picture` on HACS Update entities hardcoded the legacy CDN
URL `https://brands.home-assistant.io/_/{domain}/icon.png`. That CDN
no longer accepts new custom-integration submissions after the
brands-proxy API arrived in HA 2026.3, so Update entities for custom
integrations that ship inline `brand/` assets show broken pictures.

Switch to `/api/brands/integration/{domain}/icon.png` — a path served
by HA's local brands proxy, which resolves both core integrations (via
the upstream CDN with stale-while-revalidate) and custom integrations
(via the inline asset). The HA frontend's `addBrandsAuth` helper
appends the access token client-side when rendering the URL.

Snapshots regenerated with `pytest --snapshot-update`.

Relates to hacs#5171, hacs#5223

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant