Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,336 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

climada/util/files_handler.pyの81行目付近と、climada/util/api_client.pyの567行目付近を読みます。issueでは、URLに基づくファイル名の抽出が指摘されています。これらのダウンロードパスに関する既存のテストを確認し、クエリ文字列を含むURLのテストを追加します。両方のパスでクエリ文字列を含まないローカルファイル名が生成され、Windowsでの再現時に無効なファイル名のエラーが発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Jupyter Notebook
スター
478
フォーク
166
平均マージ
2日 31分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CLIMADA-project/climada_python のほかの issue

CLIMADA-project/climada_python の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。