alibaba/nacos · error · IllegalArgumentException
url can not be empty, url: {limitedUrl}
Error message
url can not be empty, url: {limitedUrl} What it means
Thrown when entry is 'limitedUrlMap' and an entry's URL part (before ':') is empty. This happens when the value starts with ':' or has '::', e.g. ':200'. The URL string must be non-empty.
Source
Thrown at naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java:256
boolean sendBeatOnly = Boolean.parseBoolean(value);
tempSwitchDomain.setSendBeatOnly(sendBeatOnly);
}
if (entry.equals(SwitchEntry.LIMITED_URL_MAP)) {
Map<String, Integer> limitedUrlMap = new HashMap<>(16);
if (!StringUtils.isEmpty(value)) {
String[] entries = value.split(",");
for (String each : entries) {
String[] parts = each.split(":");
if (parts.length < 2) {
throw new IllegalArgumentException("invalid input for limited urls");
}
String limitedUrl = parts[0];
if (StringUtils.isEmpty(limitedUrl)) {
throw new IllegalArgumentException(
"url can not be empty, url: " + limitedUrl);
}
int statusCode = Integer.parseInt(parts[1]);
if (statusCode <= 0) {
throw new IllegalArgumentException(
"illegal normal status code: " + statusCode);
}
limitedUrlMap.put(limitedUrl, statusCode);
}
tempSwitchDomain.setLimitedUrlMap(limitedUrlMap);
}
}
if (entry.equals(SwitchEntry.ENABLE_STANDALONE)) {View on GitHub (pinned to 9b989acdf1)
Solutions
- Ensure every URL segment before ':' is non-empty.
- Remove stray commas or leading colons from the value.
Example fix
// before PUT /v3/admin/ns/operator/switches?entry=limitedUrlMap&value=:200 // after PUT /v3/admin/ns/operator/switches?entry=limitedUrlMap&value=/nacos:200
Defensive patterns
Strategy: validation
Validate before calling
for (String entry : value.split(",")) {
String[] parts = entry.split(":", 2);
if (parts.length < 2 || parts[0].isEmpty()) {
throw new IllegalArgumentException("URL part cannot be empty");
}
} Type guard
function hasNoEmptyUrl(value: string): boolean {
return value.split(',').every(e => {
const idx = e.indexOf(':');
return idx > 0;
});
} Try / catch
try {
operatorV2Impl.updateSwitch("limitedUrlMap", value, debug);
} catch (NacosApiException e) {
if (e.getMessage().contains("url can not be empty")) {
value = value.replace(/(^|,),/g, '$1').replace(/^:/, '');
}
} Prevention
- Trim leading/trailing commas from the value.
- Ensure no entry starts with ':'.
When it happens
Trigger: PUT /v3/admin/ns/operator/switches with entry=limitedUrlMap and value where the URL segment is blank, e.g. value=':200', value='/ok:200,:500'.
Common situations: Leading/trailing commas producing empty URL parts, or typo like '::404'.
Related errors
- invalid input for limited urls
- illegal normal status code: {statusCode}
- distroThreshold can not be zero or negative: {threshold}
- illegal format, must be 'type:version', but got: {value}
- illegal version, must match: {UtilsAndCommons.VERSION_STRING
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/2cfabd874176f060.
Report an issue: GitHub.