{"record":{"id":"97e3d9583ecc106c","repo":"quarkusio/quarkus","slug":"cannot-use-methodname-method-without-a-d","errorCode":null,"errorMessage":"Cannot use `\" + methodName + \"` method without a default type configured. Consider using the `\" + methodName + \"` method accepting the type or configure the default type for the cache \" + getName()","messagePattern":"Cannot use `\" \\+ methodName \\+ \"` method without a default type configured\\. Consider using the `\" \\+ methodName \\+ \"` method accepting the type or configure the default type for the cache \" \\+ getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/redis-cache/runtime/src/main/java/io/quarkus/cache/redis/runtime/RedisCacheImpl.java","lineNumber":305,"sourceCode":"    public <K, V> Uni<Void> put(K key, V value) {\n        return put(key, new StaticSupplier<>(value));\n    }\n\n    @Override\n    public <K, V> Uni<Void> put(K key, Supplier<V> supplier) {\n        byte[] encodedKey = marshaller.encode(computeActualKey(encodeKey(key)));\n        byte[] encodedValue = marshaller.encode(supplier.get());\n        return withConnection(new Function<RedisConnection, Uni<Void>>() {\n            @Override\n            public Uni<Void> apply(RedisConnection connection) {\n                return set(connection, encodedKey, encodedValue);\n            }\n        });\n    }\n\n    private void enforceDefaultType(String methodName) {\n        if (classOfValue == null) {\n            throw new UnsupportedOperationException(\"Cannot use `\" + methodName + \"` method without a default type configured. \"\n                    + \"Consider using the `\" + methodName\n                    + \"` method accepting the type or configure the default type for the cache \"\n                    + getName());\n        }\n    }\n\n    @Override\n    public <K, V> Uni<V> getOrDefault(K key, V defaultValue) {\n        enforceDefaultType(\"getOrDefault\");\n        return getOrDefault(key, classOfValue, defaultValue);\n    }\n\n    @Override\n    public <K, V> Uni<V> getOrDefault(K key, Class<V> clazz, V defaultValue) {\n        return getOrDefault(key, (Type) clazz, defaultValue);\n    }\n\n    @Override","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-cache/runtime/src/main/java/io/quarkus/cache/redis/runtime/RedisCacheImpl.java#L287-L323","documentation":"RedisCacheImpl stores values as encoded bytes; to decode on read it needs a value Class (classOfValue), which comes from build-time value-type configuration. The type-less convenience methods (get(key, loader), getAsync, getOrDefault, getOrNull) call enforceDefaultType and fail with UnsupportedOperationException when no default type was configured for the cache.","triggerScenarios":"Calling cache.get(key, loader), getAsync, getOrDefault, or getOrNull on a Redis cache whose value type was not configured at build time (no quarkus.cache.redis.<cache>.value-type and no inferable @CacheResult type).","commonSituations":"Programmatically created/obtained caches (CacheManager.getCache) used with the untyped API; configuration-only caches without any annotated method; tests obtaining caches by name.","solutions":["Set quarkus.cache.redis.<cacheName>.value-type=... in configuration so the default type is known","Use the typed API variant: cache.get(key, MyType.class, loader) instead of the untyped get(key, loader)","Add a @CacheResult-annotated method so the value type is inferred at build time","Cast through the typed Cache interface and always pass the value Class explicitly"],"exampleFix":"// before\nV v = redisCache.get(key, k -> load(k));\n// after\nV v = redisCache.get(key, MyType.class, k -> load(k));","handlingStrategy":"validation","validationCode":"// before using untyped API\nif (System.getProperty(\"quarkus.cache.redis.my-cache.value-type\") == null) {\n    // use typed API instead\n    cache.get(key, MyType.class, loader);\n}","typeGuard":null,"tryCatchPattern":"try {\n    cache.get(key, loader);\n} catch (UnsupportedOperationException e) {\n    // fall back to typed overload\n    cache.get(key, MyType.class, loader);\n}","preventionTips":["Always configure quarkus.cache.redis.<name>.value-type for programmatically used caches","Prefer the typed get(key, Class, loader) overloads by default","Add integration tests that touch each named cache"],"tags":["quarkus","redis-cache","configuration","type-safety","runtime"],"backgroundTag":"missing-config-property","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}