Fix Nest WebRTC camera snapshot served as a PNG mislabeled image/jpeg#176885
Fix Nest WebRTC camera snapshot served as a PNG mislabeled image/jpeg#176885ajplotkin wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Hi @ajplotkin
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Hey there @allenporter, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
Corrects Nest WebRTC placeholder snapshots to report their PNG content type.
Changes:
- Sets WebRTC camera snapshots to
image/png. - Tests the content type and PNG signature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
homeassistant/components/nest/camera.py |
Advertises the placeholder as PNG. |
tests/components/nest/test_camera.py |
Verifies PNG metadata and bytes. |
| # WebRTC cameras cannot produce a snapshot, so async_camera_image | ||
| # returns the bundled placeholder, which is a PNG. Advertise the | ||
| # correct content type so it is not served as image/jpeg (the camera | ||
| # platform default), which would corrupt the image for any client | ||
| # that trusts the Content-Type header. |
| # Nest WebRTC cameras return a placeholder PNG (they cannot snapshot). | ||
| # It must be served as image/png, not the camera platform default of | ||
| # image/jpeg, so clients do not treat a PNG as a JPEG. |
| # correct content type so it is not served as image/jpeg (the camera | ||
| # platform default), which would corrupt the image for any client | ||
| # that trusts the Content-Type header. | ||
| self.content_type = "image/png" |
WebRTC-only Nest cameras cannot produce a still snapshot, so NestWebRTCEntity.async_camera_image returns the bundled placeholder image. That image is a PNG, but the camera platform serves it with the default content type of image/jpeg, producing a PNG mislabeled as JPEG over camera.snapshot and /api/camera_proxy. Set content_type to image/png on NestWebRTCEntity so the placeholder is served honestly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1d5f69e to
db519fe
Compare
|
@home-assistant ready-for-review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
homeassistant/components/nest/camera.py:260
- Remove this comment; the assignment and nearby method already make the PNG constraint clear.
# The placeholder returned by async_camera_image is a PNG, not the
# camera platform's default image/jpeg.
tests/components/nest/test_camera.py:699
- Remove this comment; the following assertions already state both the content type and file signature.
# The WebRTC placeholder is a PNG, served as image/png not the default jpeg.
homeassistant/components/nest/camera.py:261
- Restore the complete pull request template in the description; most type options, additional-information fields, and required checklist entries were deleted even though unchecked items must remain.
self.content_type = "image/png"
|
Generally looks good though: |
Addresses review feedback on home-assistant#176885. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
homeassistant/components/nest/camera.py:262
- Condense this to the non-obvious constraint; the three-line client-corruption narrative over-explains a single MIME assignment.
# The bundled placeholder is a PNG; the camera platform would otherwise
# serve it as its default image/jpeg, corrupting the frame for any
# client that trusts the Content-Type header.
self.content_type = "image/png"
|
Thanks @allenporter — both addressed:
|
Breaking change
Proposed change
WebRTC-only Nest cameras (cameras migrated to the Google Home app, which advertise
supportedProtocols: ["WEB_RTC"]and no RTSP) cannot produce a still image — the SDM on-demand snapshot API no longer exists for them. For these camerasNestWebRTCEntity.async_camera_image()returns the bundledplaceholder.png.The problem: the camera platform serves that image with the entity's
content_type, which defaults toimage/jpeg(DEFAULT_CONTENT_TYPE).placeholder.pngis a PNG. Socamera.snapshotand/api/camera_proxy/<entity>return PNG bytes labeledContent-Type: image/jpeg, HTTP 200. Anything that trusts the header (image libraries, snapshots saved with a.jpgname, notification pipelines, re-encoders) gets a corrupt "JPEG".This changes
NestWebRTCEntityto advertisecontent_type = "image/png", so the placeholder is served honestly as what it is.NestRTSPEntity(which generates real JPEG stills from its RTSP stream) is unchanged. This is a minimal correctness fix and does not change the intentional placeholder-on-tile behavior for WebRTC cameras. It does not attempt to produce real still frames for WebRTC-only cameras (the broader request in #176807) — only to stop mislabeling the placeholder that is served today.Two alternatives were weighed and rejected: (1) returning
None/raising makes/api/camera_proxy500 and breaks the dashboard tile — the placeholder-on-tile is deliberate; (2) shipping a validplaceholder.jpgchurns a binary asset and still hands automations a fake frame with no content-type signal. The PNG-as-PNG fix is smaller and equally honest.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: