{"record":{"id":"29b55e2d06727cb3","repo":"soxoj/maigret","slug":"invalid-data-file-url-url","errorCode":null,"errorMessage":"Invalid data file URL '{url}'.","messagePattern":"Invalid data file URL '(.+?)'\\.","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"maigret/sites.py","lineNumber":557,"sourceCode":"        except Exception as error:\n            raise ValueError(\n                f\"Problem parsing json contents from str\"\n                f\"'{db_str[:50]}'...:  {str(error)}.\"\n            )\n\n        return self.load_from_json(data)\n\n    def load_from_path(self, path: str) -> \"MaigretDatabase\":\n        if '://' in path:\n            return self.load_from_http(path)\n        else:\n            return self.load_from_file(path)\n\n    def load_from_http(self, url: str) -> \"MaigretDatabase\":\n        is_url_valid = url.startswith(\"http://\") or url.startswith(\"https://\")\n\n        if not is_url_valid:\n            raise FileNotFoundError(f\"Invalid data file URL '{url}'.\")\n\n        import requests\n\n        try:\n            response = requests.get(url=url)\n        except Exception as error:\n            raise FileNotFoundError(\n                f\"Problem while attempting to access \"\n                f\"data file URL '{url}':  \"\n                f\"{str(error)}\"\n            )\n\n        if response.status_code == 200:\n            try:\n                data = response.json()\n            except Exception as error:\n                raise ValueError(\n                    f\"Problem parsing json contents at \" f\"'{url}':  {str(error)}.\"","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/soxoj/maigret/blob/41674631a92a4c3ea630d046ba125cb750c03798/maigret/sites.py#L539-L575","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndb.load_from_path('raw.githubusercontent.com/soxoj/maigret/main/resources/data.json')\n\n// after\nfrom urllib.parse import urlparse\nurl = 'https://raw.githubusercontent.com/soxoj/maigret/main/resources/data.json'\nassert urlparse(url).scheme in ('http', 'https')\ndb.load_from_path(url)","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef is_http_url(s: str) -> bool:\n    return urlparse(s).scheme in ('http', 'https') and bool(urlparse(s).netloc)\n\nif not is_http_url(source):\n    raise SystemExit(f'Expected http(s) URL, got: {source}')\ndb = MaigretDatabase().load_from_path(source)","typeGuard":"from urllib.parse import urlparse\n\ndef is_http_url(s: str) -> bool:\n    u = urlparse(s)\n    return u.scheme in ('http', 'https') and bool(u.netloc)","tryCatchPattern":null,"preventionTips":["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."],"tags":["url-validation","http","maigret","input-validation"],"backgroundTag":"invalid-url-scheme","analyzedSha":"41674631a92a4c3ea630d046ba125cb750c03798","analyzedAt":"2026-08-27T02:53:58.946Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}