veza/veza-backend-api/internal
senke b875efcffc fix(middleware): bypass response cache for range-aware media endpoints
Surfaced by the v1.0.5 browser smoke test. ResponseCache captures the
entire body into a bytes.Buffer, JSON-serializes it (escaping non-UTF-8
bytes), and replays via c.Data for subsequent hits. For audio/video
streams this has two failure modes:

  1. Range headers are never honored — the cache replays the *full body*
     on every request, strips the Accept-Ranges header, and leaves the
     <audio> element unable to seek. The smoke test caught this when a
     `Range: bytes=100-299` request got back 200 OK with 48944 bytes
     instead of 206 Partial Content with 200 bytes.
  2. Non-UTF-8 bytes get escaped through the JSON round-trip (`\uFFFD`
     substitution etc.), corrupting the MP3 payload so even full plays
     can fail mid-stream.

Minimum-invasive fix: skip the cache entirely for any path containing
`/stream`, `/download`, or `/hls/`, and for any request that carries a
`Range` header (belt-and-suspenders for any future media endpoint). All
other anonymous GETs keep their 5-minute TTL.

Verified live: `GET /api/v1/tracks/:id/stream` returns
  - full: 200 OK, Accept-Ranges: bytes, Content-Length matches disk,
    body MD5 matches source file byte-for-byte
  - range: 206 Partial Content, Content-Range: bytes 100-299/48944,
    exactly 200 bytes
Browser <audio> plays end-to-end with currentTime progressing from 0 to
duration and seek to 1.5s succeeding (readyState=4, no error).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:13:02 +02:00
..
api fix(middleware): persist maintenance flag via platform_settings table 2026-04-16 14:57:06 +02:00
common v0.9.2 2026-03-05 19:27:34 +01:00
config fix(chat,config): require REDIS_URL in prod + error on in-memory fallback 2026-04-16 14:56:47 +02:00
core fix(backend,infra): send real verification emails + fail-loud in prod 2026-04-16 14:52:46 +02:00
database v0.9.4 2026-03-05 23:03:43 +01:00
dto Phase 2 stabilisation: code mort, Modal→Dialog, feature flags, tests, router split, Rust legacy 2026-02-14 17:23:32 +01:00
elasticsearch style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
email STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
errors v0.9.8 2026-03-06 19:13:16 +01:00
eventbus feat: backend — config, handlers, services, logging, migration 2026-03-23 15:46:57 +01:00
features adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
handlers fix(backend,infra): send real verification emails + fail-loud in prod 2026-04-16 14:52:46 +02:00
infrastructure v0.9.4 2026-03-05 23:03:43 +01:00
integration style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
interfaces adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
jobs feat(workers): hourly cleanup of orphan tracks stuck in processing 2026-04-16 14:57:24 +02:00
logging style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
metrics v0.9.4 2026-03-05 23:03:43 +01:00
middleware fix(middleware): bypass response cache for range-aware media endpoints 2026-04-16 16:13:02 +02:00
models style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
monitoring v0.9.4 2026-03-05 23:03:43 +01:00
pagination v0.9.8 2026-03-06 19:13:16 +01:00
recovery chore(v0.102): consolidate remaining changes — docs, frontend, backend 2026-02-20 13:02:12 +01:00
repositories fix(v0.12.6.1): remediate 2 CRITICAL + 10 HIGH + 1 MEDIUM pentest findings 2026-03-12 05:40:53 +01:00
repository fix(v0.12.6.1): update in-memory UserRepositoryImpl to accept context.Context 2026-03-12 05:47:47 +01:00
resilience chore: consolidate CI, E2E, backend and frontend updates 2026-02-17 16:43:21 +01:00
response fix: stabilize builds, tests, and lint across all stacks 2026-04-05 16:48:07 +02:00
security refactor(backend): replace 40 fmt.Printf calls with zap structured logging 2026-02-22 17:44:38 +01:00
services fix(chat,config): require REDIS_URL in prod + error on in-memory fallback 2026-04-16 14:56:47 +02:00
shutdown incus deployement fully implemented, Makefile updated and make fmt ran 2026-01-13 19:47:57 +01:00
testutils ci: retire legacy backend-ci.yml, centralize Docker probe in SkipIfNoIntegration 2026-04-15 16:12:45 +02:00
tracing incus deployement fully implemented, Makefile updated and make fmt ran 2026-01-13 19:47:57 +01:00
types feat(profile): add profile privacy toggle (B3) 2026-02-20 15:10:02 +01:00
upload [INT-015] int: Add file upload format standardization 2025-12-25 15:40:01 +01:00
utils fix(v0.12.6): apply all pentest remediations — 36 findings across 36 files 2026-03-14 00:44:46 +01:00
validators feat(v0.13.3): complete - Polish Sécurité Avancée 2026-03-13 10:09:01 +01:00
websocket style(backend): gofmt -w on 85 files (whitespace only) 2026-04-14 12:22:14 +02:00
workers fix(backend): J4 — GDPR-compliant hard delete with Redis and ES cleanup 2026-04-15 12:25:39 +02:00