Skip to content

refactor(redis): typed RedisReply instead of dynamic replies; move RedisConnectionTestFake out of lib #1571

Closed

Description

@ZhuchkaTriplesix

Problem

RedisConnection.sendCommand(List<dynamic> args) -> Future<dynamic> (lib/core/database/redis_connection.dart:391) passes raw redis package replies through. Every caller re-parses them by hand: 9 is List / length == 2 checks in redis_connection.dart alone (scan, getMaxDatabases, hash/zset/stream readers), plus redisReplyInt / RedisBulkValue.fromReply with fallbacks that hide a wrong reply shape (redisReplyInt(result, -1) turns an error into -1).

A Redis error reply and a wrong-type value look the same to callers, and arguments are List<dynamic>, so a non-string argument goes through unchecked.

RedisConnectionTestFake (:817, ~280 lines) lives in lib/ and ships in the release binary.

Fix

  • Parse once into a sealed RedisReply (RedisInt, RedisBulk(bytes), RedisSimple, RedisArray, RedisNil, RedisErrorReply) at the sendCommand boundary. Accessors like asInt() / asArray() throw a typed RedisProtocolException on a shape mismatch.
  • Typed arguments: List<Object> of String | int | Uint8List | RedisBulkValue, converted in one place (redisCommandArg).
  • Move RedisConnectionTestFake to test/ (or lib/testing/ excluded from the app).
  • Pure refactor, no behaviour change; do it after fix(redis): explorer views share one socket, so SELECT + command is not atomic; folder delete can hit another DB #1569 (Redis DB-switch fix), which touches the same file.

Activity

  1. added
    enhancementNew feature or request
    connectionsDatabase connections, URI parsing, pools
    backendBackend database driver execution and queries
    P3Low priority / Polish & Enhancements
    on Oct 13, 2026
  2. ZhuchkaTriplesix commented on Oct 25, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Fixed on dev by 25bdf09: refactor(redis): replies are parsed once into a sealed RedisReply, command arguments are typed, RedisConnectio. It reaches main with the next dev to main merge (closed after checking the code and its tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority / Polish & EnhancementsbackendBackend database driver execution and queriesconnectionsDatabase connections, URI parsing, poolsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions