[BUG]: Scraper passes headers as query params in requests.get (User-Agent never sent)

Aperta Adatta ai principianti
#161 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@Th-Shivam ci sta già lavorando.

Dal 1/10/2026.

  • #162 di @Th-Shivam — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
92/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia in backend/app/modules/scraper/extractor.py, in Article_extractor._fetch_html(). Esegui il comando uv fornito dalla directory backend/ per osservare il comportamento attuale delle richieste. Il lavoro è completato quando il User-Agent configurato viene inviato come header e gli header non vengono più serializzati nei parametri di query dell’URL.

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

Descrizione

bug
Bug Description

In backend/app/modules/scraper/extractor.py, Article_extractor._fetch_html() calls:

res = requests.get(self.url, self.headers, timeout=10)

The second positional argument of requests.get(url, params=None, **kwargs) is params, not headers. So:

  1. The custom User-Agent header is never sent.
  2. The headers dict is instead serialized into the URL query string (e.g. ?User-Agent=Mozilla%2F5.0...), producing a malformed request.

_fetch_html() backs extract_with_bs4(), which is the last-resort fallback (it runs only when Trafilatura and Newspaper3k both fail) — so exactly when robust fetching matters most, the request goes out without the intended User-Agent and with a polluted URL.

Steps to Reproduce

Deterministic, no app/keys needed — from the backend/ directory:

uv run python -c "from app.modules.scraper.extractor import Article_extractor; print(Article_extractor('https://httpbin.org/get')._fetch_html())"

Observe the response: the args object contains User-Agent (proving it was sent as a query param), and headers.User-Agent is the default python-requests/... (proving the custom UA was not applied).

Logs and Screenshots

Deterministic, no app/keys needed — from the backend/ directory:

uv run python -c "from app.modules.scraper.extractor import Article_extractor; print(Article_extractor('https://httpbin.org/get')._fetch_html())"

Observe the response: the args object contains User-Agent (proving it was sent as a query param), and headers.User-Agent is the default python-requests/... (proving the custom UA was not applied).

Environment Details
  • Present on current main (commit 70a2af4), independent of OS.
  • Backend: Python 3.13, requests>=2.32.3.
  • Root cause is a universal requests API behavior, so it reproduces in every environment.
Impact

Medium - Feature works but has issues

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Lingua principale
TypeScript
Stelle
58
Fork
90
Merge medio
11h 51m
PR unite (30g)
3

Preparare l'ambiente

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 AOSSIE-Org/Perspective

Tutte le issue di AOSSIE-Org/Perspective

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.