Web Sources crash: non-string stream fields can trigger `t.trim is not a function`

Aperta Adatta ai principianti
#856 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@petomalik6-duda ci sta già lavorando.

Dal 2/11/2026.

  • #860 di @petomalik6-duda — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Il crash si trova in sourceTitle() in web/components/details/sourcePlaybackPresentation.ts, che chiama .trim() e .split() sui campi del provider senza verificarne il tipo a runtime. Inizia da lì, poi controlla normalizeStream() in web/lib/addons.ts, che passa behaviorHints grezzi. È completato quando sourceTitle() restituisce un valore di fallback invece di lanciare un errore per valori numerici, oggetti o array in behaviorHints.filename e description, con casi di regressione per ciascuno.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug

Opening Sources for some titles can crash the whole Details screen on ARVIO Web with:

[details] TypeError: t.trim is not a function. (In 't.trim()', 't.trim' is undefined)

Observed crash report:

  • Crash ID: web-mvxwhr31
  • Version: 1793375972320
  • Time: 2026-11-01 15:03:42
  • Affected title observed: Animals / Zvieratá (2026), IMDb tt31049299, TMDb 1236045

The same account can open Sources for other movies normally. The crash was also reproducible after disabling Stremio stream addons, so this should be treated as a UI hardening issue rather than relying on every provider/source to return perfectly typed data.

Likely cause

web/components/details/sourcePlaybackPresentation.ts currently assumes provider fields are strings:

export function sourceTitle(stream: Pick<StreamSource, "source" | "addonName" | "description" | "behaviorHints">) {
  const file = stream.behaviorHints?.filename?.trim();
  if (file) return file;
  const firstLine = stream.description?.split("\n").map((line) => line.trim()).find(Boolean);
  ...
}

A runtime payload can still contain behaviorHints.filename or description with a non-string value even though the TS type says string. normalizeStream() also spreads raw behaviorHints through, so a malformed provider value can reach the UI unchanged.

Minimal safe fix

Guard runtime types before calling string methods:

export function sourceTitle(stream: Pick<StreamSource, "source" | "addonName" | "description" | "behaviorHints">) {
  const rawFilename = stream.behaviorHints?.filename;
  const file = typeof rawFilename === "string" ? rawFilename.trim() : "";
  if (file) return file;

  const description = typeof stream.description === "string" ? stream.description : "";
  const firstLine = description
    .split("\n")
    .map((line) => line.trim())
    .find(Boolean);

  if (firstLine && /[._ -]/.test(firstLine) && firstLine.length > 8 && !/^[👤💾⚙️🔗📦]/u.test(firstLine)) {
    return firstLine.replace(/\s*💾.*$/u, "").trim() || firstLine;
  }
  return typeof stream.source === "string" && stream.source
    ? stream.source
    : (typeof stream.addonName === "string" ? stream.addonName : "Source");
}

It would also be worth normalizing raw stream fields in web/lib/addons.ts so bad payloads are contained at the boundary rather than surfacing later in presentation code.

Regression test suggestion

Add cases for sourceTitle() where:

  • behaviorHints.filename is a number/object/array
  • description is a number/object
  • both are malformed and fallback to source / addonName

Expected result: Source Picker renders instead of throwing.

This is especially important because one malformed source should never take down the entire Details screen.

Lingua principale
Kotlin
Stelle
760
Fork
122
Merge medio
15h 11m
PR unite (30g)
63

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ProdigyV21/ARVIO

Tutte le issue di ProdigyV21/ARVIO

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.