apolloconfig/apollo · error · IllegalArgumentException

No such instance of instanceId:

Error message

No such instance of instanceId: 

What it means

Thrown in checkSystemHealth when the provided instanceId does not match any registered Apollo service instance across all configured environments. The controller iterates all envs and all admin/config services looking for a matching instanceId; if none is found, the IllegalArgumentException is thrown. The instanceId corresponds to a specific running Apollo service process.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:570

    String version = ApolloServer.VERSION;
    if (!Objects.equals(version, "java-null")) {
      systemInfo.setVersion(version);
    }

    for (Env env : portalSettings.getAllEnvs()) {
      systemInfo.addEnvironment(adaptEnv2EnvironmentInfo(env));
    }
    return ResponseEntity.ok(systemInfo);
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isSuperAdmin()")
  public ResponseEntity<Object> checkSystemHealth(String instanceId) {
    requirePortalUserRequest();
    ServiceDTO service = findServiceByInstanceId(instanceId);
    if (service == null) {
      throw new IllegalArgumentException("No such instance of instanceId: " + instanceId);
    }
    Health health =
        getRestTemplate().getForObject(service.getHomepageUrl() + "/health", Health.class);
    return ResponseEntity.ok(health);
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isSuperAdmin()")
  public ResponseEntity<Resource> exportAllConfigs(String envs) {
    requirePortalUserRequest();
    String filename =
        "apollo_config_export_" + DateFormatUtils.format(new Date(), "yyyy_MMdd_HH_mm_ss") + ".zip";
    List<Env> exportEnvs = Splitter.on(ENV_SEPARATOR).splitToList(envs).stream().map(this::parseEnv)
        .collect(Collectors.toList());

    return exportZipResource(filename,
        outputStream -> configsExportService.exportData(outputStream, exportEnvs),
        "export configs failed");

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Refresh the list of registered instances via the system-info endpoint and use a current, valid instanceId.
  2. Verify the instanceId string matches exactly (no trailing spaces, correct case).
  3. If the instance is genuinely down, it will not appear in the registry — restart it or check Eureka/Consul registration.

Example fix

// before
GET /system/health?instanceId=stale-or-wrong-id

// after: fetch a valid instanceId first
GET /system/info  // returns current registered instances
GET /system/health?instanceId=<valid-id-from-above>
Defensive patterns

Strategy: validation

Validate before calling

// Fetch valid instance IDs before calling health check
List<ServiceDTO> instances = getRegisteredInstances();
boolean valid = instances.stream().anyMatch(s -> instanceId.equals(s.getInstanceId()));
if (!valid) {
  throw new IllegalArgumentException("Invalid or stale instanceId: " + instanceId);
}

Try / catch

try {
  health = checkSystemHealth(instanceId);
} catch (IllegalArgumentException e) {
  // refresh instance list and retry with a valid ID, or report instance as down
}

Prevention

When it happens

Trigger: A super-admin calls the system health check endpoint with an instanceId that is not currently registered in any environment's admin or config service list (e.g. from Discovery).

Common situations: The instance went down or was deregistered between the time the caller fetched its ID and the time of the health check; the instanceId was copy-pasted incorrectly; or the instance belongs to a different Apollo cluster/deployment.

Related errors


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