{"record":{"id":"83e88192f11813a0","repo":"alibaba/nacos","slug":"endpoint-priority-must-not-be-negative","errorCode":null,"errorMessage":"Endpoint priority must not be negative","messagePattern":"Endpoint priority must not be negative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/com/alibaba/nacos/api/ai/utils/EndpointCanonicalizer.java","lineNumber":69,"sourceCode":"    /**\n     * Return a canonical copy of an Endpoint. Defaults are materialized and metadata keys are sorted.\n     *\n     * @param endpoint source Endpoint\n     * @return canonical Endpoint copy\n     * @throws IllegalArgumentException when the Endpoint is invalid\n     */\n    public static Endpoint canonicalize(Endpoint endpoint) {\n        if (endpoint == null) {\n            throw new IllegalArgumentException(\"Endpoint must not be null\");\n        }\n        CanonicalEndpointUri canonicalUri = parseUri(endpoint.getUri());\n        AgentValidationUtils.validateTransport(endpoint.getTransport());\n        \n        Integer priority = endpoint.getPriority();\n        if (priority == null) {\n            priority = DEFAULT_PRIORITY;\n        } else if (priority < 0) {\n            throw new IllegalArgumentException(\"Endpoint priority must not be negative\");\n        }\n        Double weight = endpoint.getWeight();\n        if (weight == null) {\n            weight = DEFAULT_WEIGHT;\n        } else if (weight.isNaN() || weight.isInfinite() || weight < 0D || weight > 10000D) {\n            throw new IllegalArgumentException(\"Endpoint weight must be between 0 and 10000\");\n        }\n        AgentValidationUtils.validateEndpointMetadata(endpoint.getMetadata());\n        \n        Endpoint result = new Endpoint();\n        result.setUri(canonicalUri.getUri());\n        result.setTransport(endpoint.getTransport());\n        result.setPriority(priority);\n        result.setWeight(weight);\n        result.setHealthy(endpoint.getHealthy());\n        if (endpoint.getMetadata() != null && !endpoint.getMetadata().isEmpty()) {\n            Map<String, String> sorted = new TreeMap<String, String>(endpoint.getMetadata());\n            result.setMetadata(new LinkedHashMap<String, String>(sorted));","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/api/src/main/java/com/alibaba/nacos/api/ai/utils/EndpointCanonicalizer.java#L51-L87","documentation":"Error \"Endpoint priority must not be negative\" thrown in alibaba/nacos.","triggerScenarios":"Thrown at api/src/main/java/com/alibaba/nacos/api/ai/utils/EndpointCanonicalizer.java:69 when the library encounters an invalid state.","commonSituations":"An endpoint was declared with a negative priority.","solutions":["Review the input and runtime state for endpoint priority, correct the reported problem, and retry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}