{"record":{"id":"399a4bd7c321dab2","repo":"alibaba/nacos","slug":"fieldname-must-contain-1-to-max-call-interfaces","errorCode":null,"errorMessage":"{fieldName} must contain 1 to {MAX_CALL_INTERFACES} values","messagePattern":"(.+?) must contain 1 to (.+?) values","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java","lineNumber":488,"sourceCode":"            }\n        }\n    }\n    \n    private static void validateCatalogLabels(List<String> labels, Set<String> allLabels) {\n        requireNonNull(labels, \"versionCatalog.labels\");\n        Set<String> entryLabels = new HashSet<String>();\n        for (String label : labels) {\n            AgentValidationUtils.validateNonLatestLabel(label);\n            if (!entryLabels.add(label) || !allLabels.add(label)) {\n                throw new IllegalArgumentException(\"Duplicate Version label: \" + label);\n            }\n        }\n    }\n    \n    private static void validateProtocols(List<String> protocols, String fieldName) {\n        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        }","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/utils/AgentModelValidator.java#L470-L506","documentation":"Thrown by validateProtocols when a protocols list is empty or contains more than MAX_CALL_INTERFACES (16) values. This validates the protocols field of a catalog entry (fieldName = \"versionCatalog.protocols\"). Each online Version must declare at least one protocol and at most 16. An empty protocols list is invalid because a Version must be callable.","triggerScenarios":"A catalog entry with protocols = [] (Version with no callable interface); a catalog entry advertising 17+ protocols.","commonSituations":"Building a catalog entry and leaving protocols unset (defaults to empty list); aggregating many protocol variants under one Version.","solutions":["Provide between 1 and 16 protocols for each catalog entry.","Ensure the protocols list is non-empty: at least the primary protocol must be present.","If you have more than 16 protocol variants, split the Version or drop redundant aliases."],"exampleFix":"// before\nentry.setProtocols(List.of());\n// after\nentry.setProtocols(List.of(\"mcp\"));","handlingStrategy":"validation","validationCode":"static List<String> checkProtocols(List<String> protocols, String fieldName) {\n    if (protocols == null || protocols.isEmpty() || protocols.size() > 16) {\n        throw new IllegalArgumentException(fieldName + \" must contain 1 to 16 values\");\n    }\n    return protocols;\n}","typeGuard":"static boolean protocolsValid(List<String> protocols) {\n    return protocols != null && !protocols.isEmpty() && protocols.size() <= 16;\n}","tryCatchPattern":"try {\n    AgentModelValidator.validateAgent(agent);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"must contain 1 to 16 values\")) {\n        // ensure at least the primary protocol is present\n    }\n}","preventionTips":["Always set at least one protocol on each catalog entry.","Cap protocol lists at 16 at the producer.","Treat an empty protocols list as a build error, not a default."],"tags":["ai-agent","validation","protocols","capacity-limit","illegal-argument"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}