soxoj/maigret · error · FileNotFoundError
Invalid data file URL '{url}'.
Error message
Invalid data file URL '{url}'. What it means
Maigret's MaigretDatabase.load_from_http() only accepts URLs with an http:// or https:// scheme. When the supplied string does not start with one of those prefixes, the method immediately raises FileNotFoundError('Invalid data file URL ...') before any network activity. This is a guard against feeding filesystem paths, FTP links, or malformed strings into the HTTP loader. It usually surfaces indirectly through load_from_path, which routes arguments starting with 'http' to this method.
Source
Thrown at maigret/sites.py:557
except Exception as error:
raise ValueError(
f"Problem parsing json contents from str"
f"'{db_str[:50]}'...: {str(error)}."
)
return self.load_from_json(data)
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)}."View on GitHub (pinned to 41674631a9)
Solutions
- Check the URL string: it must literally start with http:// or https://; fix the scheme/typo.
- If you meant to load a local file, call load_from_file(path) or pass a plain path that load_from_path routes correctly.
- Build URLs from a validated base (e.g. urllib.parse) or a config constant that includes the scheme.
- If loading arbitrary user-supplied sources, branch on urlparse(url).scheme in {'http','https'} before calling.
Example fix
// before
db.load_from_path('raw.githubusercontent.com/soxoj/maigret/main/resources/data.json')
// after
from urllib.parse import urlparse
url = 'https://raw.githubusercontent.com/soxoj/maigret/main/resources/data.json'
assert urlparse(url).scheme in ('http', 'https')
db.load_from_path(url) Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse
def is_http_url(s: str) -> bool:
return urlparse(s).scheme in ('http', 'https') and bool(urlparse(s).netloc)
if not is_http_url(source):
raise SystemExit(f'Expected http(s) URL, got: {source}')
db = MaigretDatabase().load_from_path(source) Type guard
from urllib.parse import urlparse
def is_http_url(s: str) -> bool:
u = urlparse(s)
return u.scheme in ('http', 'https') and bool(u.netloc) Prevention
- Normalize all remote sources through a URL-builder that always includes the scheme.
- Branch explicitly: local paths to load_from_file, http(s) URLs to load_from_http, based on urlparse.
When it happens
Trigger: Calling db.load_from_path('ftp://example.com/data.json') or load_from_http('data.json'), or passing a URL with a typo like 'htp://...' or a scheme-less host like 'raw.githubusercontent.com/...'. Any string not prefixed by http:// or https:// triggers it.
Common situations: Passing a local file path to load_from_path on a system where the routing check ('http' prefix) half-matches (e.g. a path like './http_data.json'), building the data URL from a config variable that lost its scheme, or copy-pasting an FTP/raw link without the scheme.
Related errors
- Problem while attempting to access data file URL '{url}': {
- Problem parsing json contents at '{url}': {str(error)}.
- Problem parsing json contents from file '{filename}': {str(
- Problem while attempting to access data file '{filename}'.
AI-assisted analysis of soxoj/maigret@41674631a9 (2026-08-27).
Data as JSON: /api/errors/29b55e2d06727cb3.
Report an issue: GitHub.