{"record":{"id":"f76aeb15635c78a8","repo":"languagetool-org/languagetool","slug":"could-not-load-remote-rules","errorCode":null,"errorMessage":"Could not load remote rules.","messagePattern":"Could not load remote rules\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/JLanguageTool.java","lineNumber":645,"sourceCode":"      Rule original = rules.get(i);\n      Rule transformed = mapper.apply(original);\n      if (transformed != original) {\n        rules.set(i, transformed);\n      }\n    }\n  }\n\n  public void activateRemoteRules(@Nullable File configFile) throws IOException {\n    List<RemoteRuleConfig> configs;\n    try {\n      if (configFile != null) {\n        configs = RemoteRuleConfig.load(configFile);\n      } else {\n        configs = Collections.emptyList();\n      }\n      activateRemoteRules(configs);\n    } catch (IOException e) {\n      throw new IOException(\"Could not load remote rules.\", e);\n    } catch (ExecutionException e) {\n      throw new IOException(\"Could not load remote rules configuration at \" + configFile.getAbsolutePath(), e);\n    }\n  }\n\n  public void activateRemoteRules(List<RemoteRuleConfig> configs) throws IOException {\n    // Apply A/B test filtering first - can affect which rules get enabled and thus disabled because of fallback settings\n    List<String> activeAbTestsForUser = userConfig.getAbTest();\n    List<RemoteRuleConfig> selectedConfigsByUserSettings = configs.stream()\n      .filter(config -> {\n        if (!userConfig.isPremium() && config.isPremium()) {\n          return false;\n        }\n        String excludeABTest = config.getOptions().get(\"excludeABTest\");\n        if (excludeABTest != null && activeAbTestsForUser != null &&\n          activeAbTestsForUser.stream().anyMatch(flag -> flag.matches(excludeABTest))) {\n          return false;\n        }","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/JLanguageTool.java#L627-L663","documentation":"activateRemoteRules(List) variant that loads configs from a file wraps loading failures in an IOException 'Could not load remote rules.' This fires when RemoteRuleConfig.load(configFile) itself throws IOException while reading/parsing the remote-rule configuration file.","triggerScenarios":"Calling activateRemoteRules(File configFile) (or API paths testAbFlags/testThirdPartyAI* that use it) when the config file is missing, unreadable, or has invalid remote-rule configuration content causing RemoteRuleConfig.load to throw IOException.","commonSituations":"Server deployments pointing remoteRuleConfig at a nonexistent path; malformed YAML/properties in the remote rules config; permission changes after deployment; tests enabling remote rules without a config file.","solutions":["Confirm the config file path exists and is readable by the process.","Validate the remote-rule configuration file's syntax against RemoteRuleConfig's expected format.","If no remote rules are wanted, pass an empty config / don't call the file-based overload (use the List overload).","Check the 'Caused by' IOException for the precise file or parsing problem."],"exampleFix":"// before\nlt.activateRemoteRules(new File(System.getenv(\"REMOTE_RULES\"))); // env unset -> null path\n// after\nString path = System.getenv(\"REMOTE_RULES\");\nif (path != null && new File(path).isFile()) { lt.activateRemoteRules(new File(path)); }","handlingStrategy":"validation","validationCode":"File cfg = new File(path);\nif (!cfg.isFile() || !cfg.canRead()) {\n  throw new IllegalArgumentException(\"remote rules config not readable: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  lt.activateRemoteRules(configFile);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Could not load remote rules\")) {\n    logger.error(\"Remote rules config unreadable: \" + e.getCause());\n  }\n  throw e;\n}","preventionTips":["Check config file existence/readability before activation.","Validate config syntax against RemoteRuleConfig's format.","Use the List-based activateRemoteRules overload when no file config is needed."],"tags":["remote-rules","config-loading","io","checked-exception"],"backgroundTag":"config-file-not-found","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}