{"record":{"id":"1ab38abe9aad3594","repo":"quarkusio/quarkus","slug":"the-key-key-does-not-exist","errorCode":null,"errorMessage":"The key `\" + key + \"` does not exist","messagePattern":"The key `\" \\+ key \\+ \"` does not exist","errorType":"exception","errorClass":"RedisKeyNotFoundException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/AbstractKeyCommands.java","lineNumber":140,"sourceCode":"        cmd.put(marshaller.encode(key));\n        cmd.put(timestamp);\n        cmd.putArgs(expireArgs);\n        return execute(cmd);\n    }\n\n    Uni<Response> _expireat(K key, Instant timestamp, ExpireArgs expireArgs) {\n        return _expireat(key, timestamp.getEpochSecond(), expireArgs);\n    }\n\n    Uni<Response> _expiretime(K key) {\n        nonNull(key, \"key\");\n        return execute(RedisCommand.of(EXPIRETIME).put(marshaller.encode(key)));\n    }\n\n    long decodeExpireResponse(K key, Response r) {\n        long res = r.toLong();\n        if (res == -2) {\n            throw new RedisKeyNotFoundException(new String(marshaller.encode(key), StandardCharsets.UTF_8));\n        }\n        return res;\n    }\n\n    Uni<Response> _keys(String pattern) {\n        nonNull(pattern, \"pattern\");\n        if (pattern.isBlank()) {\n            return Uni.createFrom().failure(new IllegalArgumentException(\"`pattern` must not be blank\"));\n        }\n\n        return execute(RedisCommand.of(Command.KEYS).put(pattern));\n    }\n\n    List<K> decodeKeys(Response response) {\n        return marshaller.decodeAsList(response, typeOfKey);\n    }\n\n    Uni<Response> _move(K key, long db) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/AbstractKeyCommands.java#L122-L158","documentation":"decodeExpireResponse() interprets the reply of Redis EXPIRE-style commands. Redis returns -2 when the key does not exist; the Quarkus Redis client translates that into RedisKeyNotFoundException carrying the key name, instead of returning a misleading -2. This lets callers distinguish 'key gone' from a real expiration failure.","triggerScenarios":"Calling expire/getExpire/pexpire-style key commands (e.g. ReactiveRedisDataSource.expire(key, ttl)) on a key that has been deleted or never existed; the server reply is -2.","commonSituations":"Race where another consumer/service deletes the key between existence check and EXPIRE; TTL already elapsed before the call; wrong key spelling or missing prefix in serialized key names.","solutions":["Handle RedisKeyNotFoundException in your Uni failure consumer and treat it as a non-fatal 'key missing' case.","Check key existence first with the key commands (e.g. exists/key) if the race matters to your logic.","Verify the key name/serialization matches what was actually written (prefixes, marshaller)."],"exampleFix":"// before\nredis.expire(key, Duration.ofMinutes(5)).await().indefinitely();\n\n// after\ntry {\n    redis.expire(key, Duration.ofMinutes(5)).await().indefinitely();\n} catch (RedisKeyNotFoundException e) {\n    // key no longer exists; skip TTL update\n}","handlingStrategy":"try-catch","validationCode":"Boolean exists = redis.withConnection(c -> c.key().exists(key)).await().indefinitely();","typeGuard":null,"tryCatchPattern":"try {\n    redis.expire(key, ttl).await().indefinitely();\n} catch (RedisKeyNotFoundException e) {\n    // key does not exist; handle gracefully\n}","preventionTips":["Treat 'key missing' as an expected outcome of EXPIRE-style commands.","Centralize key naming/prefixing to avoid key typos.","Check existence with key().exists() when the race with deletions matters."],"tags":["redis","quarkus","key-not-found"],"backgroundTag":"key-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}