fix(archive): stop ffmpeg 234 + corrupt-source Error Loop floods (BIT-31658) #92

Closed
spark wants to merge 2 commits from fix/BIT-31658-ffmpeg-map-corrupt-source into main
pull from: fix/BIT-31658-ffmpeg-map-corrupt-source
Owner

Summary

  • Fix 1: probe/makeWebCopy require a video stream (NotAVideo); optional -map 0:v:0?; FAILED with no_video_stream, no retry, no hub.
  • Fix 2: size vs WebDAV length + ffprobe/sharp damage → corrupt_source FAILED; UI failedCorrupt (“ficheiro corrompido na cloud”); info log only; requeue on etag change only.
  • Fix 3: confirmed isTransientStatus covers 423/429/502/503/504; permanent failures coalesced via flushIndexFailures (one hub warn per burst).

Test plan

  • pnpm exec vitest run --config vitest.unit.config.ts in apps/api — 13 passed (video + corrupt/502)
  • CI green on this PR
  • After merge/deploy: no new ffmpeg exited 234 hub errors for 48h

Parent

BIT-31657 RCA

## Summary - **Fix 1:** `probe`/`makeWebCopy` require a video stream (`NotAVideo`); optional `-map 0:v:0?`; FAILED with `no_video_stream`, no retry, no hub. - **Fix 2:** size vs WebDAV length + ffprobe/sharp damage → `corrupt_source` FAILED; UI `failedCorrupt` (“ficheiro corrompido na cloud”); info log only; requeue on etag change only. - **Fix 3:** confirmed `isTransientStatus` covers 423/429/502/503/504; permanent failures coalesced via `flushIndexFailures` (one hub warn per burst). ## Test plan - [x] `pnpm exec vitest run --config vitest.unit.config.ts` in `apps/api` — 13 passed (video + corrupt/502) - [ ] CI green on this PR - [ ] After merge/deploy: no new `ffmpeg exited 234` hub errors for 48h ## Parent BIT-31657 RCA
spark added 2 commits 2026-10-21 21:28:01 +01:00
Refuse sources with no video stream before -map 0:v:0, mark truncated/corrupt
cloud files FAILED without retry or hub noise, and coalesce permanent index
failures into one warn per burst. Surface "ficheiro corrompido na cloud" in Arquivo.

Paperclip-Issue: BIT-31658
Paperclip-Run: 501154de-aa4f-42df-a964-50809fffbb66
fix(archive): import sharp's Metadata type instead of a sharp.Metadata namespace ref (BIT-31674)
ci / rust (pull_request) Successful in 13m9s
ci / typescript (pull_request) Failing after 15m3s
f172831148
sharp's `export =` type-only namespace is not reachable off the default
import (`sharp.Metadata` doesn't resolve), which is what failed the ci /
typescript check on the BIT-31658 branch. Named-import the type like
delivery/render.ts already does for `Sharp`.

Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8)
Paperclip-Issue: BIT-31674
Paperclip-Run: eedeff3a-b5c1-4473-9613-41ef3901d9cc
spark force-pushed fix/BIT-31658-ffmpeg-map-corrupt-source from 3b20ad0df1 to f172831148 2026-10-21 21:28:01 +01:00 Compare
Author
Owner

PRE-EXISTING FAILURE
Check: ci / typescript (pull_request)
Reason: faces/worker.test.ts's mock FaceService test double does not implement refreshLineupEvents, which FaceWorker.start (apps/api/src/faces/service.ts:1352) has called since ed0adce (PR #104, already on main). Fails identically on main HEAD (58660f0), unrelated to this PR's archive/video.ts / archive/service.ts changes.
Tracking issue: BIT-31679
Evidence: main@58660f0 fails the same 2 tests (TypeError: this.service.refreshLineupEvents is not a function) when run locally with DATABASE_URL_TEST against the sandbox Postgres test container; this branch's own run (job 54160, run 22992) shows the identical failure and nothing else — rust job and the rest of apps/api test (357 passed, 9 skipped) are green.
Verified by: jos-alves
Verified at: 2026-10-21
Reverify by: 2026-10-28

Requesting a repo admin / CTO / QA sign-off per docs/CICD_POLICY_EXCEPTIONS_RUNBOOK.md §5 (BIT-31592) to merge this PR despite the red check — the fix itself (requireVideoStream before ffmpeg -map 0:v:0, plus corrupt-source handling) is for the recurring Error Loop ticket BIT-31674 (ERRCLUSTER 36b841bce18e), unmerged since this PR (and its subset #90) were opened against a stale main. Rebased onto current main here and fixed an unrelated sharp.Metadata typecheck break the branch had.

PRE-EXISTING FAILURE Check: ci / typescript (pull_request) Reason: `faces/worker.test.ts`'s mock `FaceService` test double does not implement `refreshLineupEvents`, which `FaceWorker.start` (apps/api/src/faces/service.ts:1352) has called since `ed0adce` (PR #104, already on `main`). Fails identically on `main` HEAD (`58660f0`), unrelated to this PR's `archive/video.ts` / `archive/service.ts` changes. Tracking issue: BIT-31679 Evidence: `main`@58660f0 fails the same 2 tests (`TypeError: this.service.refreshLineupEvents is not a function`) when run locally with `DATABASE_URL_TEST` against the sandbox Postgres test container; this branch's own run (job 54160, run 22992) shows the identical failure and nothing else — `rust` job and the rest of `apps/api test` (357 passed, 9 skipped) are green. Verified by: jos-alves Verified at: 2026-10-21 Reverify by: 2026-10-28 Requesting a repo admin / CTO / QA sign-off per docs/CICD_POLICY_EXCEPTIONS_RUNBOOK.md §5 (BIT-31592) to merge this PR despite the red check — the fix itself (requireVideoStream before ffmpeg -map 0:v:0, plus corrupt-source handling) is for the recurring Error Loop ticket BIT-31674 (ERRCLUSTER 36b841bce18e), unmerged since this PR (and its subset #90) were opened against a stale `main`. Rebased onto current `main` here and fixed an unrelated `sharp.Metadata` typecheck break the branch had.
Member

@cto — Gitea autopilot needs a CTO decision on BitReport.pt/photoreport#92: CI is red on the PR head.

  • Head: f17283114805
  • Detail: failed contexts: ci / typescript (pull_request)
  • The bot did not approve or schedule a merge for this head.
  • Fix the branch, approve as CTO, or close the PR. The bot re-checks on the next run.
@cto — Gitea autopilot needs a CTO decision on BitReport.pt/photoreport#92: CI is red on the PR head. - Head: `f17283114805` - Detail: failed contexts: ci / typescript (pull_request) - The bot did **not** approve or schedule a merge for this head. - Fix the branch, approve as CTO, or close the PR. The bot re-checks on the next run. <!-- gitea-autopilot-escalation kind=ci_failure sha=f17283114805 -->
Member

@cto — Gitea autopilot needs a CTO decision on BitReport.pt/photoreport#92: the PR has merge conflicts.

  • Head: f17283114805
  • The bot did not approve or schedule a merge for this head.
  • Fix the branch, approve as CTO, or close the PR. The bot re-checks on the next run.
@cto — Gitea autopilot needs a CTO decision on BitReport.pt/photoreport#92: the PR has merge conflicts. - Head: `f17283114805` - The bot did **not** approve or schedule a merge for this head. - Fix the branch, approve as CTO, or close the PR. The bot re-checks on the next run. <!-- gitea-autopilot-escalation kind=conflict sha=f17283114805 -->
Author
Owner

Conflict auto-resolution failed: could not automatically merge main into fix/BIT-31658-ffmpeg-map-corrupt-source. Manual intervention required.

BitReport PR Conflict Resolver

**Conflict auto-resolution failed**: could not automatically merge `main` into `fix/BIT-31658-ffmpeg-map-corrupt-source`. Manual intervention required. _BitReport PR Conflict Resolver_
Author
Owner

Vou fechar este PR porque todo o trabalho dele já está no main, dividido assim:

  • Fontes danificadas (moov atom not found, Invalid data, download incompleto) → corrupt_source, sem retry: #93 (BIT-31621), com corrupt-source.ts no lugar do corrupt.ts daqui.
  • .jpg com o formato errado, rejeitado antes do vips: #94, que chegou ao main pelo #114 (o #94 tinha como base o branch do #93).
  • Ficheiros sem stream de vídeo (NotAVideo / -map 0:v:0?): já cobertos pelo VideoUnsupported / no_video_stream do #90.
  • Um único warn agregado no hub por rajada de falhas, contador failedCorrupt na UI do Arquivo, etiquetas PT-PT, corrupt_source nos erros do sharp/ingest, correção do TS2503 e testes (agregação, isTransientStatus, retry de 502): #115, com a autoria do José preservada (Co-authored-by).

Ficaram de fora, de propósito, a redução do vitest.unit.config.ts e o import a meio do service.ts.

Não apaguei o branch fix/BIT-31658-ffmpeg-map-corrupt-source. Obrigado, José!

Vou fechar este PR porque todo o trabalho dele já está no `main`, dividido assim: - **Fontes danificadas (`moov atom not found`, `Invalid data`, download incompleto) → `corrupt_source`, sem retry:** #93 (BIT-31621), com `corrupt-source.ts` no lugar do `corrupt.ts` daqui. - **`.jpg` com o formato errado, rejeitado antes do vips:** #94, que chegou ao `main` pelo #114 (o #94 tinha como base o branch do #93). - **Ficheiros sem stream de vídeo (`NotAVideo` / `-map 0:v:0?`):** já cobertos pelo `VideoUnsupported` / `no_video_stream` do #90. - **Um único `warn` agregado no hub por rajada de falhas, contador `failedCorrupt` na UI do Arquivo, etiquetas PT-PT, `corrupt_source` nos erros do sharp/ingest, correção do TS2503 e testes (agregação, `isTransientStatus`, retry de 502):** #115, com a autoria do José preservada (`Co-authored-by`). Ficaram de fora, de propósito, a redução do `vitest.unit.config.ts` e o `import` a meio do `service.ts`. Não apaguei o branch `fix/BIT-31658-ffmpeg-map-corrupt-source`. Obrigado, José!
spark closed this pull request 2026-10-22 01:26:18 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.