Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Downloaded file names keep the URL query string, invalid on Windows

Offen Anfängerfreundlich
#1,336 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
85/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

Lies climada/util/files_handler.py etwa bei Zeile 81 und climada/util/api_client.py etwa bei Zeile 567. Dort weist das Issue auf die Extraktion von Dateinamen anhand von URLs hin. Prüfe die bestehenden Tests für diese Downloadpfade und ergänze Tests für URLs mit Query-Strings. Das Ziel ist erreicht, wenn beide Pfade lokale Dateinamen ohne Query-String erzeugen und die Reproduktion unter Windows keinen Fehler wegen eines ungültigen Dateinamens mehr auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

Describe the bug

download_file derives the local filename from the URL using url.split("/")[-1], which keeps the query string (climada/util/files_handler.py:81). The configured distance-to-coast URL ends in ?download=1, so the filename becomes GMT_intermediate_coast_distance_01d.zip?download=1. Since ? is not a valid character in Windows filenames, Centroids.get_dist_coast raises OSError: [Errno 22].

The same pattern is at climada/util/api_client.py:567.

To Reproduce

Steps to reproduce the behavior/error:

  1. On Windows, with no GMT_intermediate_coast_distance_01d.tif in ~/climada/data
  2. Run the code below

Code example:

from climada.util.coordinates import dist_to_coast_nasa
dist_to_coast_nasa([46.0], [8.0])
# OSError: [Errno 22] Invalid argument:
#   '...\\climada\\data\\GMT_intermediate_coast_distance_01d.zip?download=1'

Expected behavior

The query string is not part of the file name. Proposed fix at both sites:

from pathlib import PurePosixPath
from urllib.parse import urlsplit

file_name = PurePosixPath(urlsplit(url).path).name
# api_client.py: path /= unquote(PurePosixPath(urlsplit(url).path).name)

Happy to open a PR.

Screenshots

n/a

Climada Version: 6.1.1-dev (develop)

System Information (please complete the following information):

  • Operating system and version: Windows 11 (10.0.26200)
  • Python version: 3.12.13

Additional context

n/a

Vorherrschende Sprache
Jupyter Notebook
Sterne
478
Forks
166
Ø Merge
1 T. 20 Std.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus CLIMADA-project/climada_python

Alle Issues in CLIMADA-project/climada_python

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.