{"record":{"id":"33838bf2994cfc37","repo":"xtekky/gpt4free","slug":"url-must-start-with-http-or-https","errorCode":null,"errorMessage":"url must start with http:// or https://","messagePattern":"url must start with http:// or https://","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/integration/markitdown/__init__.py","lineNumber":239,"sourceCode":"            owner, repo, ref, path = (m.group(1), m.group(2), m.group(3), m.group(4))\n            # Strip a trailing slash if any\n            path = path.rstrip(\"/\")\n            return f\"https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}\"\n\n        # Tree (directory) URLs and repo roots: cannot map to a single raw file\n        return url\n\n    def convert_url(\n        self,\n        url: str,\n        *,\n        stream_info: Optional[StreamInfo] = None,\n        **kwargs: Any,\n    ) -> DocumentConverterResult:\n        if url is None or not isinstance(url, str) or url.strip() == \"\":\n            raise ValueError(\"url must be a non-empty string\")\n        if not url.startswith((\"http://\", \"https://\")):\n            raise ValueError(\"url must start with http:// or https://\")\n        if url.startswith(\"https://github.com/\"):\n            # Special case for GitHub URLs -- convert to raw content URL\n            url = self._convert_github_url_to_raw(url)\n        return super().convert_url(url, stream_info=stream_info, **kwargs)\n","sourceCodeStart":221,"sourceCodeEnd":244,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/integration/markitdown/__init__.py#L221-L244","documentation":"Thrown by MarkItDown.convert_url() when the url string does not start with http:// or https://. Only these two schemes are supported because the converter fetches over HTTP; ftp://, file://, mailto:, chrome-extension:// and bare hostnames are rejected.","triggerScenarios":"convert_url('ftp://example.com/doc.pdf'); convert_url('file:///tmp/a.html'); convert_url('example.com/page') (missing scheme); a URL stored without scheme in a database.","commonSituations":"User input like 'www.site.com/x' copied without the scheme; file:// URLs from browser drag-and-drop or local HTML that should be passed to convert() instead; scheme-relative URLs ('//cdn.site.com/a') from scraped HTML.","solutions":["Normalize the scheme first: if url.startswith('//'): url = 'https:' + url elif '://' not in url: url = 'https://' + url.","For local files use md.convert(path) / convert_stream(), not convert_url().","Drop or rewrite unsupported-scheme links earlier in your scraping pipeline."],"exampleFix":"// before\nresult = md.convert_url(\"example.com/docs/page\")\n\n// after\nurl = \"example.com/docs/page\"\nif not url.startswith((\"http://\", \"https://\")):\n    url = \"https://\" + url\nresult = md.convert_url(url)","handlingStrategy":"validation","validationCode":"def http_url(url: str) -> bool:\n    return isinstance(url, str) and url.startswith((\"http://\", \"https://\"))\n\ndef normalize(url: str) -> str:\n    if url.startswith(\"//\"):\n        return \"https:\" + url\n    if \"://\" not in url:\n        return \"https://\" + url\n    return url","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize scheme-less and scheme-relative URLs before calling convert_url.","Route local files to md.convert(), not convert_url()."],"tags":["markitdown","url","scheme","input-validation"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}