Skip to content

FileNotFoundError on URL with parameters #543

@alexgleith

Description

@alexgleith

I'm having trouble doing head and get operations on a HTTP Store. Here's code:

from obstore.store import HTTPStore

host = "https://zenodo.org"
file = "records/12756047/files/gmw_mng_2020_v4019_gtiff.zip?download=1"

store = HTTPStore(host)

info = store.head(file)
print(info)

Error is:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[4], [line 8](vscode-notebook-cell:?execution_count=4&line=8)
      4 file = "records/12756047/files/gmw_mng_2020_v4019_gtiff.zip?download=1"
      6 store = HTTPStore(host)
----> [8](vscode-notebook-cell:?execution_count=4&line=8) info = store.head(file)
      9 print(info)

File /opt/homebrew/lib/python3.11/site-packages/obstore/store.py:269, in _ObjectStoreMixin.head(self, path)
    264 def head(self, path: str) -> ObjectMeta:
    265     """Return the metadata for the specified location.
    266 
    267     Refer to the documentation for [head][obstore.head].
    268     """
--> [269](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/lib/python3.11/site-packages/obstore/store.py:269)     return obs.head(
    270         self,  # type: ignore[arg-type]
    271         path,
    272     )

FileNotFoundError: Object at location records/12756047/files/gmw_mng_2020_v4019_gtiff.zip?download=1 not found: Error performing HEAD https://zenodo.org/records/12756047/files/gmw_mng_2020_v4019_gtiff.zip%3Fdownload=1 in 1.062368084s - Server returned non-2xx status code: 404 Not Found: 

Debug source:
NotFound {
    path: "records/12756047/files/gmw_mng_2020_v4019_gtiff.zip?download=1",
    source: RetryError(
        RetryErrorImpl {
            method: HEAD,
            uri: Some(
                https://zenodo.org/records/12756047/files/gmw_mng_2020_v4019_gtiff.zip%3Fdownload=1,
            ),
            retries: 0,
            max_retries: 10,
            elapsed: 1.062368084s,
            retry_timeout: 180s,
            inner: Status {
                status: 404,
                body: Some(
                    "",
                ),
            },
        },
    ),
}

If I do it with requests, it returns 200:

import requests

host = "https://zenodo.org"
file = "records/12756047/files/gmw_mng_2020_v4019_gtiff.zip?download=1"

response = requests.head(f"{host}/{file}")

print(response)

Obstore version is 0.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions