{"record":{"id":"736660ce12b37f54","repo":"alibaba/nacos","slug":"callinterfaces-must-contain-1-to-max-call-interfa","errorCode":null,"errorMessage":"callInterfaces must contain 1 to {MAX_CALL_INTERFACES} items","messagePattern":"callInterfaces must contain 1 to (.+?) items","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java","lineNumber":504,"sourceCode":"        requireNonNull(protocols, fieldName);\n        if (protocols.isEmpty() || protocols.size() > MAX_CALL_INTERFACES) {\n            throw new IllegalArgumentException(\n                fieldName + \" must contain 1 to \" + MAX_CALL_INTERFACES + \" values\");\n        }\n        Set<String> uniqueProtocols = new HashSet<String>();\n        for (String protocol : protocols) {\n            AgentValidationUtils.validateProtocol(protocol);\n            if (!uniqueProtocols.add(protocol)) {\n                throw new IllegalArgumentException(\"Duplicate protocol: \" + protocol);\n            }\n        }\n    }\n    \n    private static void validateCallInterfaces(String namespaceId, String agentName,\n        List<AgentCallInterface> callInterfaces) {\n        requireNonNull(callInterfaces, \"callInterfaces\");\n        if (callInterfaces.isEmpty() || callInterfaces.size() > MAX_CALL_INTERFACES) {\n            throw new IllegalArgumentException(\n                \"callInterfaces must contain 1 to \" + MAX_CALL_INTERFACES + \" items\");\n        }\n        Set<String> protocols = new HashSet<String>();\n        for (AgentCallInterface callInterface : callInterfaces) {\n            validateCallInterface(namespaceId, agentName, callInterface);\n            if (!protocols.add(callInterface.getProtocol())) {\n                throw new IllegalArgumentException(\n                    \"Duplicate CallInterface protocol: \" + callInterface.getProtocol());\n            }\n        }\n    }\n    \n    private static void validateEndpointSourceOrder(List<EndpointSource> sourceOrder) {\n        requireNonNull(sourceOrder, \"endpointSourceOrder\");\n        if (sourceOrder.isEmpty() || sourceOrder.size() > EndpointSource.values().length) {\n            throw new IllegalArgumentException(\"endpointSourceOrder must contain 1 or 2 sources\");\n        }\n        Set<EndpointSource> uniqueSources = new HashSet<EndpointSource>();","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java#L486-L522","documentation":"Thrown by validateCallInterfaces when the callInterfaces list of an Agent Version detail is empty or contains more than MAX_CALL_INTERFACES (16) items. Each Version must declare at least one CallInterface (it must be callable) and at most 16. This is the container-level size check; per-item validation and per-protocol uniqueness run inside the loop.","triggerScenarios":"Submitting an AgentVersionDetail with callInterfaces = [] (a Version that cannot be called); a Version with 17+ CallInterface definitions.","commonSituations":"Creating a Version and forgetting to populate callInterfaces; migrating a config that split one interface into many protocol-specific ones.","solutions":["Provide between 1 and 16 CallInterface entries per Version.","Ensure at least the primary CallInterface is present before submission.","If more than 16 are needed, consolidate interfaces that differ only by transport detail."],"exampleFix":"// before\ndetail.setCallInterfaces(List.of());\n// after\ndetail.setCallInterfaces(List.of(primaryCallInterface));","handlingStrategy":"validation","validationCode":"static List<AgentCallInterface> checkCallInterfaces(List<AgentCallInterface> cis) {\n    if (cis == null || cis.isEmpty() || cis.size() > 16) {\n        throw new IllegalArgumentException(\"callInterfaces must contain 1 to 16 items\");\n    }\n    return cis;\n}","typeGuard":"static boolean callInterfacesValid(List<AgentCallInterface> cis) {\n    return cis != null && !cis.isEmpty() && cis.size() <= 16;\n}","tryCatchPattern":"try {\n    AgentModelValidator.validateVersionDetail(detail);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"callInterfaces must contain\")) {\n        // add at least the primary CallInterface\n    }\n}","preventionTips":["Always populate at least one CallInterface per Version.","Cap the list at 16 at the producer.","Treat an empty callInterfaces list as a build error."],"tags":["ai-agent","validation","call-interface","capacity-limit","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}