Skip to content

fix(backend): treat any 2xx upload reply as delivered - #108

Merged
simonvanlierde merged 1 commit into
mainfrom
fix/upload-malformed-2xx
Oct 27, 2026
Merged

simonvanlierde merged 1 commit into
mainfrom
fix/upload-malformed-2xx

Conversation

@simonvanlierde

Copy link
Copy Markdown
Contributor

This stops the Pi from uploading a capture twice when the backend accepts it but sends back an odd reply.

  • upload_image raised BackendUploadError on a 2xx reply that was not JSON or lacked image_id/image_url, so the queue retried and the backend stored the capture again. Only a bad image_url was handled.
  • Any 2xx is now delivered: the reply is parsed as far as it can be, a warning says what was wrong, and UploadedImageInfo carries None for the unusable parts (image_id is now str | None).
  • BackendPushSink.put falls back to the local capture id when the backend id is missing, so StoredImage.image_id and the capture response always have an id.
  • Non-2xx replies and upload_preview_thumbnail (which needs its URL) still raise.

Tests: new unit tests for a non-JSON 2xx, a 2xx missing fields and the sink fallback; the first two failed with BackendUploadError before the change. just check run, 916 passed, 1 skipped.

- a non-JSON or incomplete 2xx reply no longer raises, so the queue does not retry and the backend does not store the capture twice
- UploadedImageInfo.image_id is optional; BackendPushSink falls back to the local capture id
- upload_preview_thumbnail still raises when the reply has no usable URL

Signed-off-by: Simon van Lierde <simonvanlierde@gmail.com>
@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 12 untouched benchmarks


Comparing fix/upload-malformed-2xx (0e1f971) with main (7ebf2e5)

Open in CodSpeed

@simonvanlierde
simonvanlierde merged commit 6b65157 into main Oct 27, 2026
11 checks passed
@simonvanlierde
simonvanlierde deleted the fix/upload-malformed-2xx branch October 27, 2026 15:07
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