{"record":{"id":"c59166be845287b0","repo":"arduino/Arduino","slug":"failed-to-parse-s","errorCode":null,"errorMessage":"Failed to parse: %s","messagePattern":"Failed to parse: (.+?)","errorType":"exception","errorClass":"LocationParseError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/util.py","lineNumber":154,"sourceCode":"        path = delim + path_\n\n    # Auth\n    if '@' in url:\n        auth, url = url.split('@', 1)\n\n    # IPv6\n    if url and url[0] == '[':\n        host, url = url[1:].split(']', 1)\n\n    # Port\n    if ':' in url:\n        _host, port = url.split(':', 1)\n\n        if not host:\n            host = _host\n\n        if not port.isdigit():\n            raise LocationParseError(\"Failed to parse: %s\" % url)\n\n        port = int(port)\n\n    elif not host and url:\n        host = url\n\n    if not path:\n        return Url(scheme, auth, host, port, path, query, fragment)\n\n    # Fragment\n    if '#' in path:\n        path, fragment = path.split('#', 1)\n\n    # Query\n    if '?' in path:\n        path, query = path.split('?', 1)\n\n    return Url(scheme, auth, host, port, path, query, fragment)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/util.py#L136-L172","documentation":"urllib3.util.parse_url parses URL strings into host/port/scheme components. This LocationParseError is raised when the portion after ':' used as a port is not a string of digits, so the URL's authority component cannot be interpreted as host:port.","triggerScenarios":"Passing URLs like 'http://host:notaport/', 'example.com:8080x', or a password/URL fragment containing a colon in the wrong place ('http://user:p@ss:word@host') so the splitter treats ':word' as a port; passing a bare 'host:path' string to connection_from_url or get_host.","commonSituations":"Embedding unencoded credentials (password with ':' or '@') in URLs; typos in port numbers; passing proxy strings like 'http://proxy:3128extra' from env vars; forgetting the scheme and passing 'localhost:8080/path' variants that confuse the parser in this vendored version.","solutions":["Fix the URL so any text after the host colon is a numeric port.","Percent-encode special characters in username/password: use urllib.parse.quote on credentials before building the URL, or pass auth=('user','pass') to requests.","Validate with urllib3.util.parse_url in a try/except before use to fail fast with a clearer message.","Check HTTP(S)_PROXY/NO_PROXY env vars for malformed 'host:port' values."],"exampleFix":"// before\nurl = 'http://user:p@ss:word@example.com/'  # ':word' parsed as port\n// after\nurl = 'http://user:p%40ss%3Aword@example.com/'","handlingStrategy":"validation","validationCode":"from urllib3.util import parse_url\ndef valid_url(u):\n    try:\n        parsed = parse_url(u)\n        return parsed.host is not None and (parsed.port is None or str(parsed.port).isdigit())\n    except Exception:\n        return False\nassert valid_url(url), 'malformed URL: %s' % url","typeGuard":null,"tryCatchPattern":"from urllib3.exceptions import LocationParseError\ntry:\n    pool = urllib3.connection_from_url(url)\nexcept LocationParseError as e:\n    raise ValueError('Cannot parse URL %r: %s' % (url, e))","preventionTips":["Percent-encode credentials (use urllib.parse.quote) instead of embedding raw passwords.","Validate URLs from env/config at startup with parse_url.","Never hand-build host:port strings; use urlencode/urllib helpers.","Keep the scheme explicit in stored base URLs."],"tags":["url","parsing","urllib3","invalid-input"],"backgroundTag":"invalid-url-format","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}