{"record":{"id":"85e26eac599422b9","repo":"rohitg00/ai-engineering-from-scratch","slug":"requirements-must-identify-one-primary-integration","errorCode":null,"errorMessage":"requirements must identify one primary integration shape","messagePattern":"requirements must identify one primary integration shape","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/25-integration-protocols-identity-and-least-privilege/code/main.py","lineNumber":35,"sourceCode":"    local_automation: bool = False\n    cross_agent_delegation: bool = False\n    direct_service_call: bool = False\n    long_running: bool = False\n\n\ndef select_protocol(requirements: IntegrationRequirements) -> str:\n    selected = [\n        name\n        for condition, name in (\n            (requirements.dynamic_discovery, \"mcp\"),\n            (requirements.local_automation, \"cli\"),\n            (requirements.cross_agent_delegation, \"agent-to-agent\"),\n            (requirements.direct_service_call, \"api\"),\n        )\n        if condition\n    ]\n    if len(selected) != 1:\n        raise ValueError(\"requirements must identify one primary integration shape\")\n    protocol = selected[0]\n    if requirements.long_running and protocol == \"cli\":\n        return \"cli-with-durable-job\"\n    return protocol\n\n\n@dataclass(frozen=True)\nclass Principal:\n    principal_id: str\n    scopes: frozenset[str]\n    approved_actions: frozenset[str] = frozenset()\n\n\n@dataclass(frozen=True)\nclass ToolContract:\n    name: str\n    description: str\n    required_scopes: frozenset[str]","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/25-integration-protocols-identity-and-least-privilege/code/main.py#L17-L53","documentation":"Raised in select_protocol when the IntegrationRequirements flags match zero or multiple protocol shapes. Exactly one of dynamic_discovery (mcp), local_automation (cli), cross_agent_delegation (agent-to-agent), or direct_service_call (api) must be true; the chooser refuses ambiguous or empty requirements.","triggerScenarios":"Thrown at certifications/claude/lessons/25-integration-protocols-identity-and-least-privilege/code/main.py:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set exactly one primary requirement flag to True in the IntegrationRequirements dataclass","Split genuinely distinct integration needs into separate requirement objects","Remove contradictory flags (e.g. local_automation plus direct_service_call) from the scenario"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}