{"record":{"id":"a49c1f129b9110f0","repo":"apolloconfig/apollo","slug":"no-such-instance-of-instanceid-a49c1f","errorCode":null,"errorMessage":"No such instance of instanceId: {}","messagePattern":"No such instance of instanceId: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java","lineNumber":119,"sourceCode":"        for (final ServiceDTO s : envInfo.getAdminServices()) {\n          if (instanceId.equals(s.getInstanceId())) {\n            service = s;\n            break;\n          }\n        }\n      }\n      if (envInfo.getConfigServices() != null) {\n        for (final ServiceDTO s : envInfo.getConfigServices()) {\n          if (instanceId.equals(s.getInstanceId())) {\n            service = s;\n            break;\n          }\n        }\n      }\n    }\n\n    if (service == null) {\n      throw new IllegalArgumentException(\"No such instance of instanceId: \" + instanceId);\n    }\n\n    return restTemplate.getForObject(service.getHomepageUrl() + \"/health\", Health.class);\n  }\n\n  private EnvironmentInfo adaptEnv2EnvironmentInfo(final Env env) {\n    EnvironmentInfo environmentInfo = new EnvironmentInfo();\n    String metaServerAddresses = portalMetaDomainService.getMetaServerAddress(env);\n\n    environmentInfo.setEnv(env);\n    environmentInfo.setActive(portalSettings.isEnvActive(env));\n    environmentInfo.setMetaServerAddress(metaServerAddresses);\n\n    String selectedMetaServerAddress = portalMetaDomainService.getDomain(env);\n    try {\n      environmentInfo\n          .setConfigServices(getServerAddress(selectedMetaServerAddress, CONFIG_SERVICE_URL_PATH));\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-fetch the system-info list to get the current instanceId values and retry with a valid one.","Verify the meta server URL for the env is reachable and returns the config/admin services list (GET <meta>/services/config).","Confirm the target config-service/admin-service instance is actually registered and healthy before polling its health.","If building a client, guard for IllegalArgumentException / 500 and surface a 'instance not found' message rather than crashing."],"exampleFix":"// before\nrestTemplate.getForObject(portal + \"/system-info/health?instanceId=\" + id, String.class);\n\n// after\nif (!knownInstanceIds.contains(id)) {\n  return \"instance \" + id + \" is not currently registered\";\n}\ntry {\n  return restTemplate.getForObject(portal + \"/system-info/health?instanceId=\" + id, String.class);\n} catch (HttpClientErrorException | IllegalArgumentException e) {\n  return \"health lookup failed: \" + e.getMessage();\n}","handlingStrategy":"validation","validationCode":"// validate instanceId against currently registered services before calling health\nList<Env> envs = portalSettings.getAllEnvs();\nSet<String> valid = new HashSet<>();\nfor (Env env : envs) {\n  EnvironmentInfo info = adaptEnv2EnvironmentInfo(env);\n  if (info.getAdminServices() != null) info.getAdminServices().forEach(s -> valid.add(s.getInstanceId()));\n  if (info.getConfigServices() != null) info.getConfigServices().forEach(s -> valid.add(s.getInstanceId()));\n}\nif (!valid.contains(instanceId)) {\n  return ResponseEntity.status(HttpStatus.NOT_FOUND).body(\"instance not registered: \" + instanceId);\n}","typeGuard":"// no compile-time type; narrow at runtime\nboolean isRegisteredInstance(String id, Collection<ServiceDTO> known) {\n  return known != null && known.stream().map(ServiceDTO::getInstanceId).anyMatch(id::equals);\n}","tryCatchPattern":"try { health = checkHealth(instanceId); }\ncatch (IllegalArgumentException e) { /* instance not found; refresh service list */ }","preventionTips":["Refresh the system-info/service list before invoking health checks.","Treat instanceId as ephemeral; do not cache it long-term.","Handle IllegalArgumentException/HTTP 500 from this endpoint as 'not found'."],"tags":["apollo-portal","service-discovery","instance-id","system-info"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}