{"record":{"id":"893abeb4e6a37e58","repo":"alibaba/nacos","slug":"illegal-normal-status-code-statuscode","errorCode":null,"errorMessage":"illegal normal status code: {statusCode}","messagePattern":"illegal normal status code: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java","lineNumber":262,"sourceCode":"                Map<String, Integer> limitedUrlMap = new HashMap<>(16);\n                \n                if (!StringUtils.isEmpty(value)) {\n                    String[] entries = value.split(\",\");\n                    for (String each : entries) {\n                        String[] parts = each.split(\":\");\n                        if (parts.length < 2) {\n                            throw new IllegalArgumentException(\"invalid input for limited urls\");\n                        }\n                        \n                        String limitedUrl = parts[0];\n                        if (StringUtils.isEmpty(limitedUrl)) {\n                            throw new IllegalArgumentException(\n                                \"url can not be empty, url: \" + limitedUrl);\n                        }\n                        \n                        int statusCode = Integer.parseInt(parts[1]);\n                        if (statusCode <= 0) {\n                            throw new IllegalArgumentException(\n                                \"illegal normal status code: \" + statusCode);\n                        }\n                        \n                        limitedUrlMap.put(limitedUrl, statusCode);\n                        \n                    }\n                    \n                    tempSwitchDomain.setLimitedUrlMap(limitedUrlMap);\n                }\n            }\n            \n            if (entry.equals(SwitchEntry.ENABLE_STANDALONE)) {\n                \n                if (StringUtils.isNotEmpty(value)) {\n                    tempSwitchDomain.setEnableStandalone(Boolean.parseBoolean(value));\n                }\n            }\n            ","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java#L244-L280","documentation":"Thrown when entry is 'limitedUrlMap' and the status code parsed from the part after ':' is <= 0. Status codes must be positive integers (e.g. 200, 403, 503).","triggerScenarios":"PUT /v3/admin/ns/operator/switches with entry=limitedUrlMap and value with non-positive status code, e.g. value='/nacos:0', value='/nacos:-1', or non-integer value='/nacos:abc' (which throws NumberFormatException before this check).","commonSituations":"Using 0 to mean 'disabled', passing negative codes, or typos in the numeric portion.","solutions":["Use a valid positive HTTP status code (1-999), typically 200, 403, 429, or 503.","Ensure the segment after ':' is a parseable positive integer."],"exampleFix":"// before\nPUT /v3/admin/ns/operator/switches?entry=limitedUrlMap&value=/nacos:0\n// after\nPUT /v3/admin/ns/operator/switches?entry=limitedUrlMap&value=/nacos:403","handlingStrategy":"validation","validationCode":"for (String entry : value.split(\",\")) {\n    String[] parts = entry.split(\":\", 2);\n    int code = Integer.parseInt(parts[1]);\n    if (code <= 0) {\n        throw new IllegalArgumentException(\"Status code must be positive: \" + code);\n    }\n}","typeGuard":"function hasValidStatusCodes(value: string): boolean {\n  return value.split(',').every(e => {\n    const parts = e.split(':');\n    const code = parseInt(parts[1], 10);\n    return !isNaN(code) && code > 0;\n  });\n}","tryCatchPattern":"try {\n  operatorV2Impl.updateSwitch(\"limitedUrlMap\", value, debug);\n} catch (NacosApiException e) {\n  if (e.getMessage().contains(\"illegal normal status code\")) {\n    // fix status codes to valid positive values\n  }\n}","preventionTips":["Use standard HTTP status codes (200, 403, 429, 503).","Never use 0 or negative values."],"tags":["naming","switch","validation","limited-url"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}