{"record":{"id":"add6c33371247a15","repo":"affaan-m/ECC","slug":"remote-import-host-could-not-be-resolved-parsed","errorCode":null,"errorMessage":"remote import host could not be resolved: {parsed.hostname}","messagePattern":"remote import host could not be resolved: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/continuous-learning-v2/scripts/instinct-cli.py","lineNumber":200,"sourceCode":"    if \"..\" in instinct_id:\n        return False\n    if instinct_id.startswith(\".\"):\n        return False\n    return bool(re.match(r\"^[A-Za-z0-9][A-Za-z0-9._-]*$\", instinct_id))\n\n\ndef _validate_import_url(source: str) -> str:\n    \"\"\"Validate remote instinct imports before opening a network connection.\"\"\"\n    parsed = urllib.parse.urlparse(source)\n    if parsed.scheme != \"https\":\n        raise ValueError(\"remote instinct imports require https URLs\")\n    if not parsed.hostname:\n        raise ValueError(\"remote import URL is missing a hostname\")\n\n    try:\n        addr_infos = socket.getaddrinfo(parsed.hostname, parsed.port or 443, type=socket.SOCK_STREAM)\n    except socket.gaierror as exc:\n        raise ValueError(f\"remote import host could not be resolved: {parsed.hostname}\") from exc\n\n    for family, _, _, _, sockaddr in addr_infos:\n        host = sockaddr[0]\n        try:\n            ip = ipaddress.ip_address(host)\n        except ValueError:\n            continue\n        if (\n            ip.is_private\n            or ip.is_loopback\n            or ip.is_link_local\n            or ip.is_multicast\n            or ip.is_reserved\n            or ip.is_unspecified\n        ):\n            raise ValueError(f\"remote import host resolves to a non-public address: {host}\")\n\n    return urllib.parse.urlunparse(parsed)","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/continuous-learning-v2/scripts/instinct-cli.py#L182-L218","documentation":"Raised by _validate_import_url when socket.getaddrinfo fails with gaierror, meaning the hostname in the import URL cannot be resolved to an IP address. The CLI converts the DNS failure into a ValueError that keeps the offending hostname in the message. This blocks fetch attempts against unreachable or mistyped hosts.","triggerScenarios":"Importing from a hostname that does not exist (typo like instinct.example.comm), DNS outage on the machine, offline environment, or a hostname only resolvable on a private network.","commonSituations":"Typo in a hand-typed URL; corporate VPN required for internal DNS; /etc/resolv.conf misconfigured; container without network access.","solutions":["Correct the hostname in the URL (check spelling/TLD).","Verify DNS works: run `python -c \"import socket; print(socket.getaddrinfo('host', 443))\"` or `nslookup <host>`.","Connect to the VPN/corporate network if the host is internal-only.","Retry after fixing network/DNS configuration; treat the raised ValueError as a user-facing 'cannot resolve host' message."],"exampleFix":"# before\nurl = \"https://instincts.example.comm/file.yaml\"\n# after\nurl = \"https://instincts.example.com/file.yaml\"  # fixed typo","handlingStrategy":"validation","validationCode":"import socket\ntry:\n    socket.getaddrinfo(hostname, 443)\nexcept socket.gaierror as e:\n    raise ValueError(f\"cannot resolve {hostname}\") from e","typeGuard":null,"tryCatchPattern":"try:\n    cli_import(url=source)\nexcept ValueError as e:\n    if \"could not be resolved\" in str(e):\n        print(f\"check DNS/VPN for host: {source}\")","preventionTips":["Spell-check hostnames; verify with nslookup/dig first","Connect VPN before importing from internal hosts","Handle offline environments by queueing imports","Fix resolv.conf/network in containers before remote imports"],"tags":["python","dns","network","cli"],"backgroundTag":"connection-refused","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}