{"record":{"id":"1a25c4ab9c8b7e22","repo":"redis/jedis","slug":"unrecognized-header-header","errorCode":null,"errorMessage":"Unrecognized header: ${header}","messagePattern":"Unrecognized header: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/search/SearchBuilderFactory.java","lineNumber":52,"sourceCode":"    }\n  };\n\n  public static final Builder<Map<String, Map<String, Double>>> SEARCH_SPELLCHECK_RESPONSE\n      = new Builder<Map<String, Map<String, Double>>>() {\n\n    private static final String TERM = \"TERM\";\n    private static final String RESULTS = \"results\";\n\n    @Override\n    public Map<String, Map<String, Double>> build(Object data) {\n      List rawDataList = (List) data;\n      if (rawDataList.isEmpty()) return Collections.emptyMap();\n\n      if (rawDataList.get(0) instanceof KeyValue) {\n        KeyValue rawData = (KeyValue) rawDataList.get(0);\n        String header = STRING.build(rawData.getKey());\n        if (!RESULTS.equals(header)) {\n          throw new IllegalStateException(\"Unrecognized header: \" + header);\n        }\n\n        return ((List<KeyValue>) rawData.getValue()).stream().collect(Collectors.toMap(\n            rawTerm -> STRING.build(rawTerm.getKey()),\n            rawTerm -> ((List<List<KeyValue>>) rawTerm.getValue()).stream()\n                .collect(Collectors.toMap(entry -> STRING.build(entry.get(0).getKey()),\n                      entry -> BuilderFactory.DOUBLE.build(entry.get(0).getValue()))),\n            (x, y) -> x, LinkedHashMap::new));\n      }\n\n      Map<String, Map<String, Double>> returnTerms = new LinkedHashMap<>(rawDataList.size());\n\n      for (Object rawData : rawDataList) {\n        List<Object> rawElements = (List<Object>) rawData;\n\n        String header = STRING.build(rawElements.get(0));\n        if (!TERM.equals(header)) {\n          throw new IllegalStateException(\"Unrecognized header: \" + header);","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/search/SearchBuilderFactory.java#L34-L70","documentation":"SEARCH ProfilingBuilderFactory/SuggestBuilder's build() parses the reply of an FT.SUGGET-style/suffix command expecting the first KeyValue's key to be the RESULTS header. An IllegalStateException is thrown when the reply's header does not match, meaning the server response shape differs from what the builder expects.","triggerScenarios":"Calling the associated search profiling/suggestion API whose raw reply's first element is not the expected RESULTS KeyValue — e.g. running against a server version with a different response format or a wrong command reply reaching the builder.","commonSituations":"RediSearch server/client version mismatch; custom modules or proxies altering reply layout; passing the builder the wrong command's reply.","solutions":["Align RediSearch module and Jedis versions so reply formats match","Verify you are invoking the correct command/API whose reply format is RESULTS-prefixed","Inspect the raw reply (e.g. via a lower-level sendCommand) to confirm the actual server response shape"],"exampleFix":"// before\nObject reply = connection.sendCommand(ProfilerCommand.LEX...);\n// wrong reply fed to builder expecting RESULTS header\n// after\n// use the matching command/API or upgrade client so header matches RESULTS","handlingStrategy":"validation","validationCode":"// confirm reply shape before building\nif (!(raw instanceof java.util.List) || ((java.util.List<?>) raw).isEmpty()) throw new IllegalStateException(\"unexpected empty reply\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Jedis and RediSearch module versions matched","Feed each builder only replies from its own command","Log raw replies when upgrading server versions"],"tags":["redisearch","search","response-parsing"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}