{"record":{"id":"c0ea07386239ba9b","repo":"alibaba/nacos","slug":"min-default-cache-time-is-too-small-1000","errorCode":null,"errorMessage":"min default cache time  is too small(<1000)","messagePattern":"min default cache time  is too small\\(<1000\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java","lineNumber":176,"sourceCode":"            }\n            \n            if (entry.equals(SwitchEntry.PUSH_CACHE_MILLIS)) {\n                long cacheMillis = Long.parseLong(value);\n                \n                if (cacheMillis < SwitchEntry.MIN_PUSH_CACHE_TIME_MIILIS) {\n                    throw new IllegalArgumentException(\n                        \"min cache time for http or tcp is too small(<10000)\");\n                }\n                \n                tempSwitchDomain.setDefaultPushCacheMillis(cacheMillis);\n            }\n            \n            // extremely careful while modifying this, cause it will affect all clients without pushing enabled\n            if (entry.equals(SwitchEntry.DEFAULT_CACHE_MILLIS)) {\n                long cacheMillis = Long.parseLong(value);\n                \n                if (cacheMillis < SwitchEntry.MIN_CACHE_TIME_MIILIS) {\n                    throw new IllegalArgumentException(\n                        \"min default cache time  is too small(<1000)\");\n                }\n                \n                tempSwitchDomain.setDefaultCacheMillis(cacheMillis);\n            }\n            \n            if (entry.equals(SwitchEntry.MASTERS)) {\n                List<String> masters = Arrays.asList(value.split(\",\"));\n                tempSwitchDomain.setMasters(masters);\n            }\n            \n            if (entry.equals(SwitchEntry.DISTRO)) {\n                boolean enabled = Boolean.parseBoolean(value);\n                tempSwitchDomain.setDistroEnabled(enabled);\n            }\n            \n            if (entry.equals(SwitchEntry.CHECK) || entry.equals(SwitchEntry.HEALTH_CHECK_ENABLED)) {\n                boolean enabled = Boolean.parseBoolean(value);","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java#L158-L194","documentation":"Thrown when entry is 'defaultCacheMillis' and the parsed long is below MIN_CACHE_TIME_MIILIS (1000 ms). This is the default client cache interval for clients without push enabled. The source comment warns: 'extremely careful while modifying this, cause it will affect all clients without pushing enabled.'","triggerScenarios":"PUT /v3/admin/ns/operator/switches with entry=defaultCacheMillis and value < 1000, e.g. value=500, value=100, value=0.","commonSituations":"Passing seconds instead of milliseconds, or trying to reduce polling interval below the safety floor of 1 second.","solutions":["Set defaultCacheMillis to >= 1000 (1 second).","Verify the value is in milliseconds.","Understand that lowering this affects ALL non-push clients globally."],"exampleFix":"// before\nPUT /v3/admin/ns/operator/switches?entry=defaultCacheMillis&value=500\n// after\nPUT /v3/admin/ns/operator/switches?entry=defaultCacheMillis&value=1000","handlingStrategy":"validation","validationCode":"long cacheMillis = Long.parseLong(value);\nif (cacheMillis < 1000) {\n    throw new IllegalArgumentException(\"defaultCacheMillis must be >= 1000\");\n}","typeGuard":"function isValidDefaultCacheMillis(v: number): boolean {\n  return v >= 1000;\n}","tryCatchPattern":"try {\n  operatorV2Impl.updateSwitch(\"defaultCacheMillis\", String.valueOf(cacheMillis), debug);\n} catch (NacosApiException e) {\n  if (e.getMessage().contains(\"too small\")) {\n    cacheMillis = 1000;\n  }\n}","preventionTips":["Remember this value affects ALL non-push clients globally.","Validate in milliseconds before calling."],"tags":["naming","switch","validation","cache-millis"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}