Skip to content

Replace non-human-readable keys and values with placeholder text#238

Merged
ArgusLi merged 12 commits intomainfrom
feature/prevent-display-not-human-readable-keys
Mar 10, 2026
Merged

Replace non-human-readable keys and values with placeholder text#238
ArgusLi merged 12 commits intomainfrom
feature/prevent-display-not-human-readable-keys

Conversation

@ArgusLi
Copy link
Contributor

@ArgusLi ArgusLi commented Mar 10, 2026

Description

When Valkey stores binary or non-UTF-8 data, the Key Browser can display garbled, non-human-readable strings. This PR detects such content and replaces it with a "Not human readable" message instead.

Human-readability detection

A string is considered human-readable if at least 90% of its characters are printable ASCII (code points 32–126, plus tab, line feed, and carriage return). A ratio-based approach is used instead of a strict all-or-nothing check because some otherwise readable strings can contain stray non-printable bytes (e.g. a trailing null byte or minor encoding artifact). The 90% threshold cleanly separates "mostly text" content from truly binary data, which typically has a printable ratio well below 50%.

Change Visualization

image

const code = char.charCodeAt(0)

if (
(code >= 32 && code <= 126) // letters, numbers, punctuations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm what about unicode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation only considers ASCII printable characters and doesn't consider any non-english characters.

I'll make the change to fix this.

@ArgusLi ArgusLi force-pushed the feature/prevent-display-not-human-readable-keys branch from 61955e9 to b2771ee Compare March 10, 2026 17:27
ArgusLi added 11 commits March 10, 2026 12:33
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
… that.

Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
This alternative to elements is displayed if there's a reason why elements cannot be populated. Currently it's only if size is larger than the threshold.

Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
Signed-off-by: Argus Li <contactme@chunkeili.com>
@ArgusLi ArgusLi force-pushed the feature/prevent-display-not-human-readable-keys branch from 5a6b429 to 9b27a92 Compare March 10, 2026 19:34
Signed-off-by: Argus Li <43020525+ArgusLi@users.noreply.github.com>
@ArgusLi ArgusLi merged commit 7333e4a into main Mar 10, 2026
7 checks passed
@ArgusLi ArgusLi deleted the feature/prevent-display-not-human-readable-keys branch March 10, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants