apolloconfig/apollo · warning · IllegalArgumentException

No such instance of instanceId: {}

Error message

No such instance of instanceId: {}

What it means

Thrown by SystemInfoController.checkHealth (GET /system-info/health?instanceId=...) when no config-service or admin-service instance across any environment matches the supplied instanceId. The portal iterates every env's admin+config ServiceDTO lists and, finding no match, raises IllegalArgumentException. It is an IllegalArgumentException (not BadRequestException), so it typically surfaces as HTTP 500 unless a global handler maps it.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java:119

        for (final ServiceDTO s : envInfo.getAdminServices()) {
          if (instanceId.equals(s.getInstanceId())) {
            service = s;
            break;
          }
        }
      }
      if (envInfo.getConfigServices() != null) {
        for (final ServiceDTO s : envInfo.getConfigServices()) {
          if (instanceId.equals(s.getInstanceId())) {
            service = s;
            break;
          }
        }
      }
    }

    if (service == null) {
      throw new IllegalArgumentException("No such instance of instanceId: " + instanceId);
    }

    return restTemplate.getForObject(service.getHomepageUrl() + "/health", Health.class);
  }

  private EnvironmentInfo adaptEnv2EnvironmentInfo(final Env env) {
    EnvironmentInfo environmentInfo = new EnvironmentInfo();
    String metaServerAddresses = portalMetaDomainService.getMetaServerAddress(env);

    environmentInfo.setEnv(env);
    environmentInfo.setActive(portalSettings.isEnvActive(env));
    environmentInfo.setMetaServerAddress(metaServerAddresses);

    String selectedMetaServerAddress = portalMetaDomainService.getDomain(env);
    try {
      environmentInfo
          .setConfigServices(getServerAddress(selectedMetaServerAddress, CONFIG_SERVICE_URL_PATH));

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Re-fetch the system-info list to get the current instanceId values and retry with a valid one.
  2. Verify the meta server URL for the env is reachable and returns the config/admin services list (GET <meta>/services/config).
  3. Confirm the target config-service/admin-service instance is actually registered and healthy before polling its health.
  4. If building a client, guard for IllegalArgumentException / 500 and surface a 'instance not found' message rather than crashing.

Example fix

// before
restTemplate.getForObject(portal + "/system-info/health?instanceId=" + id, String.class);

// after
if (!knownInstanceIds.contains(id)) {
  return "instance " + id + " is not currently registered";
}
try {
  return restTemplate.getForObject(portal + "/system-info/health?instanceId=" + id, String.class);
} catch (HttpClientErrorException | IllegalArgumentException e) {
  return "health lookup failed: " + e.getMessage();
}
Defensive patterns

Strategy: validation

Validate before calling

// validate instanceId against currently registered services before calling health
List<Env> envs = portalSettings.getAllEnvs();
Set<String> valid = new HashSet<>();
for (Env env : envs) {
  EnvironmentInfo info = adaptEnv2EnvironmentInfo(env);
  if (info.getAdminServices() != null) info.getAdminServices().forEach(s -> valid.add(s.getInstanceId()));
  if (info.getConfigServices() != null) info.getConfigServices().forEach(s -> valid.add(s.getInstanceId()));
}
if (!valid.contains(instanceId)) {
  return ResponseEntity.status(HttpStatus.NOT_FOUND).body("instance not registered: " + instanceId);
}

Type guard

// no compile-time type; narrow at runtime
boolean isRegisteredInstance(String id, Collection<ServiceDTO> known) {
  return known != null && known.stream().map(ServiceDTO::getInstanceId).anyMatch(id::equals);
}

Try / catch

try { health = checkHealth(instanceId); }
catch (IllegalArgumentException e) { /* instance not found; refresh service list */ }

Prevention

When it happens

Trigger: Calling GET /system-info/health with an instanceId that is stale, from a different deployment, mistyped, or whose service has deregistered from the meta server. Also when the meta server returns an empty/partial services list so the running instance is simply not enumerated.

Common situations: Stale UI tab holding an old instanceId after config-service restart/scale; misconfigured dev.meta/pro.meta so service discovery returns nothing; pointing the portal at the wrong meta server; copy-paste typo in the instanceId query param.

Related errors


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/a49c1f129b9110f0. Report an issue: GitHub.