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

legacy fallback is not allowlisted for this endpoint

Error message

legacy fallback is not allowlisted for this endpoint

What it means

Error "legacy fallback is not allowlisted for this endpoint" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:344

def select_era(
    observation: dict[str, Any],
    policy: str,
    legacy_allowed: bool = False,
    legacy_evidence: dict[str, Any] | None = None,
) -> str:
    if policy not in {"strict", "fallback"}:
        raise ValueError("policy must be strict or fallback")
    kind = observation.get("kind")
    if kind == "discover_success":
        return "modern"
    if kind == "jsonrpc_error" and observation.get("code") in MODERN_ERROR_CODES:
        return "modern"
    if policy == "strict":
        raise ProtocolViolation("modern support was not proven; strict policy forbids fallback")
    if kind not in {"empty", "timeout", "connection_closed", "unrecognized"}:
        raise ProtocolViolation("probe outcome is not safe evidence for fallback")
    if not legacy_allowed:
        raise ProtocolViolation("legacy fallback is not allowlisted for this endpoint")
    if not isinstance(legacy_evidence, dict):
        raise ProtocolViolation("inconclusive modern probe is not positive legacy evidence")
    if (
        legacy_evidence.get("kind") != "initialize_success"
        or legacy_evidence.get("protocolVersion") != LEGACY_VERSION
    ):
        raise ProtocolViolation("legacy probe did not prove the configured legacy era")
    return "legacy"


def notification_http_outcome(request: dict[str, Any]) -> tuple[int, None]:
    if "id" in request:
        raise ValueError("request has an id and is not a notification")
    return 202, None


@dataclass(frozen=True)
class Transcript:

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:344 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/402f75ecfdbb9493. Report an issue: GitHub.