redis/jedis · error · JedisException

Unknown type

Error message

Unknown type: ${str}

What it means

JsonBuilderFactory's type converter only maps a fixed set of JSON schema type names (string, integer, number, boolean, object, array) to Java classes. An unrecognized name throws JedisException("Unknown type: ...").

Solutions

  1. Use only supported type names: string, integer, number, boolean, object, array
  2. Fix typos and casing in the schema type field
  3. Pre-validate the schema's type values before passing to JsonBuilderFactory

Example fix

// before
{"type": "float"}
// after
{"type": "number"}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Set.of("string","integer","number","boolean","object","array");
if (!allowed.contains(schemaType)) { throw new IllegalArgumentException("unsupported schema type: " + schemaType); }

Try / catch

try { Class<?> c = JsonBuilderFactory...build(str); } catch (JedisException e) { log.error("Unknown schema type: {}", str); throw new IllegalArgumentException(e); }

Prevention

When it happens

Trigger: Calling build()/the type-mapping method with a schema type string not in the supported set, e.g. "null", "any", "float", or an uppercase/wrongly-spelled type name like "String" or "arry".

Common situations: Feeding a JSON schema with non-standard type names; hand-written schemas with typos; schema versions using type names the factory doesn't know.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/31e837a02907110e. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/json/JsonBuilderFactory.java:37

      if (data == null) return null;
      String str = STRING.build(data);
      switch (str) {
        case "null":
          return null;
        case "boolean":
          return boolean.class;
        case "integer":
          return int.class;
        case "number":
          return float.class;
        case "string":
          return String.class;
        case "object":
          return Object.class;
        case "array":
          return List.class;
        default:
          throw new JedisException("Unknown type: " + str);
      }
    }

    @Override
    public String toString() {
      return "Class<?>";
    }
  };

  public static final Builder<List<Class<?>>> JSON_TYPE_LIST = new Builder<List<Class<?>>>() {
    @Override
    public List<Class<?>> build(Object data) {
      List<Object> list = (List<Object>) data;
      List<Class<?>> classes = new ArrayList<>(list.size());
      for (Object elem : list) {
        try {
          classes.add(JSON_TYPE.build(elem));
        } catch (JedisException je) {

View on GitHub (pinned to 6dac31d4c2)