Skip to content

fix(valkey): hscan raises on a field name that is not UTF-8 #7507

Done

Description

@dan-petty

Problem Description

ValkeyClient.hscan in src/devops_cli/valkey/client.py decodes each field name with a strict bytes(name).decode() after the call returns, outside _call. A field name that is not UTF-8 raises UnicodeDecodeError. That is not a ValkeyError, so ValkeyCacheTier and its breaker let it through, and the read does not fail soft (ADR 0023 section 2). The field values decode with "replace", so only the names are at risk.

Each brain read goes through hscan (BrainIndex.watermark, and BrainIndex.items and tools of PR #7496). A UnicodeDecodeError from the brain digest stops the round of the alternatives check, because _settled catches only GitHubNotAnIssueError.

Reproduction Steps

  1. HSET roadmap:v1:brain-item:acme/widgets:3 "\xff\xfe" x in the roadmap state store, where item 3 is a near item of item 7.
  2. Run the alternatives check of item 7, or call read_digest(index, 7, ()).

Expected vs Actual Behavior

Expected: the read gives the fields with a replaced name, or the tier counts it as a store failure, and the digest is empty.

Actual: UnicodeDecodeError goes up through read_digest and stops the round.

Environment Diagnostics

Found in the review of PR #7496 on 2026-11-28 with a scratch script on its branch. No process of the project writes such a field name today, so only a hand-written key can cause it.

Logs, Traces, or Terminal Output

None.

Source

Source: #7496

Activity

  1. added
    type/bug
    source/agent
    status/new
    value/medium
    effort/low
    scope/valkey
    on Nov 28, 2026
  2. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 28, 2026
  4. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor

    Fixed on main by #7517 (commit 0e2070a): ValkeyClient.hscan now decodes each field name with errors="replace" (src/devops_cli/valkey/client.py:335), and tests/valkey/test_valkey_cache_tier.py::test_the_cache_tier_reads_a_hash_whose_field_name_is_not_utf8 covers it.

  5. removed
    status/new
    on Nov 28, 2026
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

    effort/lowpriority/p2-mediumscope/valkeysource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions