soxoj/maigret · error · FileNotFoundError

Problem while attempting to access data file URL '{url}': {

Error message

Problem while attempting to access data file URL '{url}':  {str(error)}

What it means

load_from_http() wraps the requests.get(url) call in a broad try/except; any exception raised while performing the HTTP request (DNS failure, connection refused, TLS error, timeout, missing 'requests' package import errors inside the call scope) is re-raised as FileNotFoundError with the original error text appended. It signals the remote JSON database could not be fetched at all, not that it was malformed. The original cause is not chained (no 'from error'), so the appended string is the only diagnostic.

Source

Thrown at maigret/sites.py:564

    def load_from_path(self, path: str) -> "MaigretDatabase":
        if '://' in path:
            return self.load_from_http(path)
        else:
            return self.load_from_file(path)

    def load_from_http(self, url: str) -> "MaigretDatabase":
        is_url_valid = url.startswith("http://") or url.startswith("https://")

        if not is_url_valid:
            raise FileNotFoundError(f"Invalid data file URL '{url}'.")

        import requests

        try:
            response = requests.get(url=url)
        except Exception as error:
            raise FileNotFoundError(
                f"Problem while attempting to access "
                f"data file URL '{url}':  "
                f"{str(error)}"
            )

        if response.status_code == 200:
            try:
                data = response.json()
            except Exception as error:
                raise ValueError(
                    f"Problem parsing json contents at " f"'{url}':  {str(error)}."
                )
        else:
            raise FileNotFoundError(
                f"Bad response while accessing " f"data file URL '{url}'."
            )

        return self.load_from_json(data)

View on GitHub (pinned to 41674631a9)

Solutions

  1. Verify network connectivity and the URL from the same environment (curl -I <url>).
  2. Fix proxy/TLS issues: set HTTPS_PROXY, or install the corporate CA bundle if certificate verification fails.
  3. Pin a local copy of the data file and call load_from_file() instead of fetching remotely.
  4. If requests.get fails due to the missing library, install dependencies: pip install maigret[full] / pip install requests.

Example fix

// before
db = MaigretDatabase().load_from_path('https://unreachable-host.example/data.json')

// after
import requests
url = 'https://raw.githubusercontent.com/soxoj/maigret/main/resources/data.json'
try:
    requests.get(url, timeout=10).raise_for_status()
except requests.RequestException:
    db = MaigretDatabase().load_from_file('resources/data.json')  # local fallback
else:
    db = MaigretDatabase().load_from_path(url)
Defensive patterns

Strategy: try-catch

Validate before calling

import requests

resp = requests.get(url, timeout=15)  # probe before handing to maigret
resp.raise_for_status()

Try / catch

from maigret.sites import MaigretDatabase

try:
    db = MaigretDatabase().load_from_http(url)
except FileNotFoundError as err:
    # covers both invalid-URL and request-failure cases; inspect message or pre-validate URL
    logger.warning('remote db unavailable, falling back to local: %s', err)
    db = MaigretDatabase().load_from_file(local_path)

Prevention

When it happens

Trigger: Calling db.load_from_http('https://down.example.com/data.json') where the host does not resolve, the server refuses connections, a proxy blocks the request, TLS certificate verification fails, or the machine is offline. Also raised if requests.get itself throws for any reason (e.g. invalid URL characters that pass the scheme check).

Common situations: Corporate networks with mandatory proxies, CI runners without network access, mistyped hostnames, captive portals, self-signed certificates, or attempting to fetch from a raw GitHub URL while rate-limited/blocked. Note there is no timeout parameter, so hangs are also possible.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of soxoj/maigret@41674631a9 (2026-08-27). Data as JSON: /api/errors/8e7284b5ab2a806a. Report an issue: GitHub.