kovidgoyal/kitty · warning · ValueError
Invalid URL
Error message
Invalid URL
What it means
open_url_parse is a func_with_args handler for the launch/open_url action in mouse/map mappings. urlparse is applied to the URL; if the result lacks a scheme or netloc, ValueError('Invalid URL') is raised — but the handler catches it, logs 'Ignoring invalid URL string: ...' and returns the partial URL anyway.
Source
Thrown at kitty/options/utils.py:161
return func, parts
return 'kitten', parts[1:]
@func_with_args('open_url')
def open_url_parse(func: str, rest: str) -> FuncArgsType:
from urllib.parse import urlparse
url = ''
try:
url = python_string(rest)
tokens = urlparse(url)
if not all(
(
tokens.scheme,
tokens.netloc,
)
):
raise ValueError('Invalid URL')
except Exception:
log_error('Ignoring invalid URL string: ' + rest)
return func, (url,)
@func_with_args('goto_tab')
def goto_tab_parse(func: str, rest: str) -> FuncArgsType:
n = int(rest)
if n < 0:
n += 1 # goto_tab subtracts 1 from its argument, this maps both zero and -1 to previous tab for backwards compat.
return func, (n,)
@func_with_args('detach_window')
def detach_window_parse(func: str, rest: str) -> FuncArgsType:
if rest not in ('new', 'new-tab', 'new-tab-left', 'new-tab-right', 'ask', 'tab-prev', 'tab-left', 'tab-right'):
log_error(f'Ignoring invalid detach_window argument: {rest}')
rest = 'new'View on GitHub (pinned to 6d5d0c4406)
Solutions
- Include a full URL with scheme and host, e.g. https://example.com
- Check kitty's log (Ctrl+Shift+F1 / kitty.err) for 'Ignoring invalid URL string' and correct the offending map
- Quoting the URL in the config avoids tokenization issues
Example fix
# before mouse_map left click ungrabbed open_url example.com # after mouse_map left click ungrabbed open_url https://example.com
Defensive patterns
Strategy: fallback
Validate before calling
from urllib.parse import urlparse
u = urlparse(candidate)
if not (u.scheme and u.netloc):
candidate = 'https://' + candidate # normalize before use Type guard
def is_valid_url(v: str) -> bool:
u = urlparse(v)
return bool(u.scheme and u.netloc) Try / catch
try:
u = urlparse(v)
assert u.scheme and u.netloc
except Exception:
log.warning('ignoring invalid URL: %s', v)
u = None Prevention
- Always write URLs with scheme and host in map/launch actions
- Check kitty's error log for 'Ignoring invalid URL string' after config changes
When it happens
Trigger: A config line like `mouse_map left click ungrabbed open_url foo` (no scheme/host), or a URL string that urlparse cannot decompose into scheme+netloc. The error is logged and the string is still passed to the handler.
Common situations: Hand-writing mouse_map/launch URL actions with a bare hostname or relative path; trailing characters after the URL; the error appears in kitty's error log while browsing despite 'working' configs.
Related errors
- Ignoring invalid mouse action: {val}
- Mouse button: {xbutton} not recognized, ignoring
- Mouse event type: {event} not recognized, ignoring
- Mouse modes: {modes} not recognized, ignoring
- This should be run as kitten broadcast
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/19e36e12485926bc.
Report an issue: GitHub.