xtekky/gpt4free · error · ValueError
url must not be None
Error message
url must not be None
What it means
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.
Source
Thrown at g4f/integration/markitdown/__init__.py:195
def _convert_github_url_to_raw(url: str) -> str:
"""Convert a github.com URL to a raw.githubusercontent.com content URL.
Handles the following patterns:
- https://github.com/{owner}/{repo}/blob/{ref}/{path}
-> https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}
- https://github.com/{owner}/{repo}/raw/{ref}/{path}
-> https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}
- https://gist.github.com/{user}/{gist_id}
-> https://gist.githubusercontent.com/{user}/{gist_id}/raw
- URLs already pointing to raw.githubusercontent.com or
gist.githubusercontent.com are returned unchanged.
Tree URLs (directories) and repository root URLs cannot be converted
to a single raw file and are returned unchanged so the caller can
decide how to handle them.
"""
if url is None:
raise ValueError("url must not be None")
# Already raw -- nothing to do
if url.startswith(
(
"https://raw.githubusercontent.com/",
"https://gist.githubusercontent.com/",
)
):
return url
# Gist URLs
m = re.match(
r"^https?://gist\.github\.com/([^/]+)/([0-9a-fA-F]+)(?:/.*)?$",
url,
)
if m:
user, gist_id = m.group(1), m.group(2)
return f"https://gist.githubusercontent.com/{user}/{gist_id}/raw"View on GitHub (pinned to 973504e177)
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).
Example fix
// before
raw = md._convert_github_url_to_raw(link) # link may be None
// after
if not link:
raise ValueError('no github link provided')
raw = md._convert_github_url_to_raw(link) Defensive patterns
Strategy: validation
Validate before calling
def can_convert_github(url) -> bool:
return isinstance(url, str) and url.startswith("https://github.com/") Prevention
- Never call the private _convert_github_url_to_raw with possibly-None values.
- Use the public convert_url(), which validates input itself.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- url must be a non-empty string
- url must start with http:// or https://
- MarkItDown requires media to be provided.
- MarkItDown is not installed. Please install it with `pip ins
- Could not convert stream to Markdown. No converter attempted
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/6b114ef3fdd39ec6.
Report an issue: GitHub.