rohitg00/ai-engineering-from-scratch · error · ValueError

publisher domain must be a valid multi-label DNS name

Error message

publisher domain must be a valid multi-label DNS name

What it means

Error "publisher domain must be a valid multi-label DNS name" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/19-capstone-projects/13-mcp-server-with-registry/code/main.py:381

        issues.append("remote profile requires a non-empty remotes list")
    else:
        for index, remote in enumerate(remotes):
            if not isinstance(remote, dict):
                issues.append(f"remotes[{index}] must be an object")
                continue
            if remote.get("type") not in {"streamable-http", "sse"}:
                issues.append(f"remotes[{index}].type must be streamable-http or sse")
            remote_url = remote.get("url")
            if not isinstance(remote_url, str) or REMOTE_URL_RE.fullmatch(remote_url) is None:
                issues.append(f"remotes[{index}].url must be an http(s) URL template")
    return issues


def reverse_dns_namespace(domain: str) -> str:
    normalized = domain.casefold().rstrip(".")
    labels = normalized.split(".")
    if len(labels) < 2 or any(DOMAIN_LABEL_RE.fullmatch(label) is None for label in labels):
        raise ValueError("publisher domain must be a valid multi-label DNS name")
    return ".".join(reversed(labels))


def validate_publisher_namespace(document: object, verified_domain: str) -> list[str]:
    """Check domain ownership outside the server.json shape contract."""
    if not isinstance(document, dict) or not isinstance(document.get("name"), str):
        return []
    namespace = document["name"].partition("/")[0]
    expected = reverse_dns_namespace(verified_domain)
    if namespace != expected and not namespace.startswith(f"{expected}."):
        return [
            f"name namespace must be {expected} or its child for verified domain {verified_domain}"
        ]
    return []


def validate_runtime_alignment(document: dict, discovery: object) -> list[str]:
    """Compare publication identity with the live server/discover identity."""

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/19-capstone-projects/13-mcp-server-with-registry/code/main.py:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/9d36f3b80898ad8e. Report an issue: GitHub.