{"record":{"id":"6b114ef3fdd39ec6","repo":"xtekky/gpt4free","slug":"url-must-not-be-none","errorCode":null,"errorMessage":"url must not be None","messagePattern":"url must not be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/integration/markitdown/__init__.py","lineNumber":195,"sourceCode":"    def _convert_github_url_to_raw(url: str) -> str:\n        \"\"\"Convert a github.com URL to a raw.githubusercontent.com content URL.\n\n        Handles the following patterns:\n        - https://github.com/{owner}/{repo}/blob/{ref}/{path}\n            -> https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}\n        - https://github.com/{owner}/{repo}/raw/{ref}/{path}\n            -> https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}\n        - https://gist.github.com/{user}/{gist_id}\n            -> https://gist.githubusercontent.com/{user}/{gist_id}/raw\n        - URLs already pointing to raw.githubusercontent.com or\n          gist.githubusercontent.com are returned unchanged.\n\n        Tree URLs (directories) and repository root URLs cannot be converted\n        to a single raw file and are returned unchanged so the caller can\n        decide how to handle them.\n        \"\"\"\n        if url is None:\n            raise ValueError(\"url must not be None\")\n\n        # Already raw -- nothing to do\n        if url.startswith(\n            (\n                \"https://raw.githubusercontent.com/\",\n                \"https://gist.githubusercontent.com/\",\n            )\n        ):\n            return url\n\n        # Gist URLs\n        m = re.match(\n            r\"^https?://gist\\.github\\.com/([^/]+)/([0-9a-fA-F]+)(?:/.*)?$\",\n            url,\n        )\n        if m:\n            user, gist_id = m.group(1), m.group(2)\n            return f\"https://gist.githubusercontent.com/{user}/{gist_id}/raw\"","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/integration/markitdown/__init__.py#L177-L213","documentation":"Thrown by MarkItDown's _convert_github_url_to_raw() when url is None. This helper maps github.com blob/gist URLs to raw.githubusercontent.com URLs and treats None as a programming error (the public convert_url validates earlier). It is a defensive precondition check on an internal method.","triggerScenarios":"Calling _convert_github_url_to_raw(None) directly, or subclass/caller code passing a URL variable that was never assigned (e.g. extracted from a redirect or JSON field that was absent).","commonSituations":"Custom integrations that resolve a GitHub link from user input or an API response where the field can be null; refactors that moved the None-check burden to callers of the private method.","solutions":["Guard at the call site: only invoke the helper when url is truthy.","Prefer the public convert_url(url), which already raises a clearer error for None/empty strings.","Fix the upstream extraction so the URL variable is always a string (provide a default or fail early)."],"exampleFix":"// before\nraw = md._convert_github_url_to_raw(link)  # link may be None\n\n// after\nif not link:\n    raise ValueError('no github link provided')\nraw = md._convert_github_url_to_raw(link)","handlingStrategy":"validation","validationCode":"def can_convert_github(url) -> bool:\n    return isinstance(url, str) and url.startswith(\"https://github.com/\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call the private _convert_github_url_to_raw with possibly-None values.","Use the public convert_url(), which validates input itself."],"tags":["markitdown","url","precondition"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}