affaan-m/ECC · error · ValueError

remote import host could not be resolved

Error message

remote import host could not be resolved: {parsed.hostname}

What it means

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.

Solutions

  1. Correct the hostname in the URL (check spelling/TLD).
  2. Verify DNS works: run `python -c "import socket; print(socket.getaddrinfo('host', 443))"` or `nslookup <host>`.
  3. Connect to the VPN/corporate network if the host is internal-only.
  4. Retry after fixing network/DNS configuration; treat the raised ValueError as a user-facing 'cannot resolve host' message.

Example fix

# before
url = "https://instincts.example.comm/file.yaml"
# after
url = "https://instincts.example.com/file.yaml"  # fixed typo
Defensive patterns

Strategy: validation

Validate before calling

import socket
try:
    socket.getaddrinfo(hostname, 443)
except socket.gaierror as e:
    raise ValueError(f"cannot resolve {hostname}") from e

Try / catch

try:
    cli_import(url=source)
except ValueError as e:
    if "could not be resolved" in str(e):
        print(f"check DNS/VPN for host: {source}")

Prevention

When it happens

Trigger: 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.

Common situations: Typo in a hand-typed URL; corporate VPN required for internal DNS; /etc/resolv.conf misconfigured; container without network access.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/add6c33371247a15. Report an issue: GitHub.

Appendix: source

Thrown at skills/continuous-learning-v2/scripts/instinct-cli.py:200

    if ".." in instinct_id:
        return False
    if instinct_id.startswith("."):
        return False
    return bool(re.match(r"^[A-Za-z0-9][A-Za-z0-9._-]*$", instinct_id))


def _validate_import_url(source: str) -> str:
    """Validate remote instinct imports before opening a network connection."""
    parsed = urllib.parse.urlparse(source)
    if parsed.scheme != "https":
        raise ValueError("remote instinct imports require https URLs")
    if not parsed.hostname:
        raise ValueError("remote import URL is missing a hostname")

    try:
        addr_infos = socket.getaddrinfo(parsed.hostname, parsed.port or 443, type=socket.SOCK_STREAM)
    except socket.gaierror as exc:
        raise ValueError(f"remote import host could not be resolved: {parsed.hostname}") from exc

    for family, _, _, _, sockaddr in addr_infos:
        host = sockaddr[0]
        try:
            ip = ipaddress.ip_address(host)
        except ValueError:
            continue
        if (
            ip.is_private
            or ip.is_loopback
            or ip.is_link_local
            or ip.is_multicast
            or ip.is_reserved
            or ip.is_unspecified
        ):
            raise ValueError(f"remote import host resolves to a non-public address: {host}")

    return urllib.parse.urlunparse(parsed)

View on GitHub (pinned to 8321021c54)