25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(redis): fall back to value length when range rejected
OkaneGaiefa329731d94
diff --git a/apps/desktop/src/components/redis/RedisValueViewer.loadFailure.spec.ts b/apps/desktop/src/components/redis/RedisValueViewer.loadFailure.spec.tsnew file mode 100644index 0000000000..d15d5b2b80--- /dev/null+++ b/apps/desktop/src/components/redis/RedisValueViewer.loadFailure.spec.ts@@ -0,0 +1,170 @@+// @vitest-environment happy-dom+//+// 覆盖键详情的读取失败路径:服务端拒绝读取时(早期是 TongRDS 对越界+// GETRANGE 直接报错),面板以前是纯空白,失败只进了调试日志,用户看不出+// 是读取失败还是键里没有内容。++import { createApp, defineComponent, h, nextTick } from "vue";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { createI18n } from "vue-i18n";++const mocks = vi.hoisted(() => ({+ redisGetValue: vi.fn(),+ redisGetTtl: vi.fn(),+ toast: vi.fn(),+}));++vi.mock("@/lib/backend/api", () => ({+ redisGetValue: mocks.redisGetValue,+ redisGetTtl: mocks.redisGetTtl,+ redisSetTtl: vi.fn(),+ redisSetExpireAt: vi.fn(),+}));++vi.mock("@/composables/useEditorFontFamilyStyle", () => ({+ useEditorFontFamilyStyle: () => ({}),+}));++vi.mock("@/composables/useToast", () => ({+ useToast: () => ({ toast: mocks.toast }),+}));++vi.mock("@/lib/common/shikiJsonHighlighter", () => ({+ createShikiJsonHighlighter: vi.fn().mockResolvedValue(() => ""),+}));++// Render the string body without mounting CodeMirror and its stores.+vi.mock("@/components/redis/RedisJsonEditor.vue", async () => {+ const { defineComponent, h, ref } = await import("vue");+ return {+ default: defineComponent({+ props: { modelValue: String, readOnly: Boolean, autofocus: Boolean },+ emits: ["update:modelValue"],+ setup(props, { emit }) {+ const input = ref<HTMLTextAreaElement>();+ return () =>+ h("textarea", {+ ref: input,+ value: props.modelValue,+ readonly: props.readOnly,+ onInput: (event: Event) => emit("update:modelValue", (event.target as HTMLTextAreaElement).value),+ });+ },+ }),+ };+});++import RedisValueViewer from "./RedisValueViewer.vue";++const mountedApps: Array<{ unmount: () => void; host: HTMLElement }> = [];++function createLocalStorage(): Storage {+ const entries = new Map<string, string>();+ return {+ get length() {+ return entries.size;+ },+ clear() {+ entries.clear();+ },+ getItem(key) {+ return entries.get(key) ?? null;+ },+ key(index) {+ return [...entries.keys()][index] ?? null;+ },+ removeItem(key) {+ entries.delete(key);+ },+ setItem(key, value) {+ entries.set(key, String(value));+ },+ };+}++beforeEach(() => {+ vi.clearAllMocks();+ vi.stubGlobal("localStorage", createLocalStorage());+});++afterEach(() => {+ for (const { unmount, host } of mountedApps.splice(0)) {+ unmount();+ host.remove();+ }+ vi.unstubAllGlobals();+});++const testI18nMessages = {+ en: {+ common: { loading: "Loading" },+ grid: { refresh: "Refresh" },+ },+};++async function settle() {+ await nextTick();+ await Promise.resolve();+ await nextTick();+}++async function mountViewer() {+ const host = document.createElement("div");+ document.body.append(host);+ const app = createApp(+ defineComponent({+ setup() {+ return () => h(RedisValueViewer, { connectionId: "connection", db: 0, keyDisplay: "key", keyRaw: "key" });+ },+ }),+ );+ app.use(createI18n({ legacy: false, locale: "en", messages: testI18nMessages, missingWarn: false, fallbackWarn: false }));+ app.mount(host);+ mountedApps.push({ unmount: () => app.unmount(), host });+ await settle();+}++function stringValue(text: string) {+ return {+ key_display: "key",+ key_raw: "key",+ ttl: -1,+ redis_type: "string",+ data: {+ kind: "string",+ content: { raw_base64: btoa(text), encoding: "utf8" },+ total_bytes: text.length,+ truncated: false,+ },+ };+}++describe("RedisValueViewer 读取失败", () => {+ it("读取失败时显示原因而不是空白面板", async () => {+ mocks.redisGetValue.mockRejectedValue(new Error("0-65536 is out of bounds"));++ await mountViewer();++ const failure = document.querySelector("[data-redis-value-load-error]");+ expect(failure).not.toBeNull();+ expect(failure?.textContent).toContain("0-65536 is out of bounds");+ expect(mocks.toast).toHaveBeenCalledWith("0-65536 is out of bounds", 4000);+ });++ it("重试按钮重新读取并渲染值", async () => {+ mocks.redisGetValue.mockRejectedValueOnce(new Error("0-65536 is out of bounds")).mockResolvedValueOnce(stringValue("hello"));++ await mountViewer();+ expect(document.querySelector("[data-redis-value-load-error]")).not.toBeNull();++ const retry = document.querySelector<HTMLButtonElement>("[data-redis-value-load-retry]");+ expect(retry).not.toBeNull();+ retry!.click();+ await settle();+ await settle();++ expect(mocks.redisGetValue).toHaveBeenCalledTimes(2);+ expect(document.querySelector("[data-redis-value-load-error]")).toBeNull();+ expect(document.querySelector<HTMLTextAreaElement>("textarea")?.value).toBe("hello");+ });+});diff --git a/apps/desktop/src/components/redis/RedisValueViewer.vue b/apps/desktop/src/components/redis/RedisValueViewer.vueindex 17c28c0253..80a7ba8f6c 100644--- a/apps/desktop/src/components/redis/RedisValueViewer.vue+++ b/apps/desktop/src/components/redis/RedisValueViewer.vue@@ -114,6 +114,8 @@ const REDIS_COLLECTION_ROW_HEIGHT = 32;const REDIS_STREAM_MIN_ROW_HEIGHT = 96;const data = ref<RedisValue | null>(null);const loading = ref(false);+/** The last failed read. Without it a failed first read leaves the panel empty. */+const loadError = ref("");const downloadingLargeValue = ref(false);const loadingMore = ref(false);const showRenameKeyDialog = ref(false);@@ -1902,6 +1904,30 @@ async function load(options: { background?: boolean; notifyParent?: boolean; pre}}+/**+ * Load the key and keep a failed read visible.+ *+ * `load()` rethrows so its callers can react to the failure, but the first+ * read of a key has no caller waiting for it: the panel stayed empty and the+ * failure only reached the debug log. The error is kept in the panel and+ * reported once, so a server that rejects the read is visible instead of+ * looking like an empty value.+ */+async function loadForDisplay(options: { background?: boolean; notifyParent?: boolean; preserveDraft?: boolean; selectDefaultMember?: boolean; shouldApply?: () => boolean } = {}): Promise<boolean> {+ loadError.value = "";+ try {+ return await load(options);+ } catch (error) {+ loadError.value = errorMessage(error);+ toast(loadError.value, 4000);+ return false;+ }+}++function retryValueLoad() {+ void loadForDisplay();+}+async function loadMore() {if (!data.value || !hasMore.value || loadingMore.value || searchLoading.value) return;if (!collectionSearchSupported.value) return;@@ -2943,7 +2969,7 @@ watch(() => props.previewLimitKiB,() => {// Apply the new limit immediately, but never replace an edited value.- if (redisValueViewerIsActive && !hasUnsavedRedisDraft.value) void load();+ if (redisValueViewerIsActive && !hasUnsavedRedisDraft.value) void loadForDisplay();},);@@ -2975,7 +3001,7 @@ watch(showMemberDetail, (open) => {onMounted(() => {window.addEventListener("pointerdown", handleValueViewerPointerDown, true);document.addEventListener("visibilitychange", handleDocumentVisibilityChange);- void load();+ void loadForDisplay();void createShikiJsonHighlighter({appearance: () => redisJsonAppearance.value,})@@ -2989,7 +3015,7 @@ onMounted(() => {onActivated(() => {redisValueViewerIsActive = true;collectionSearchController.setActive(true);- if (!loading.value && (!data.value || (loadedPreviewLimitBytes !== redisValuePreviewLimitBytes(props.previewLimitKiB) && !hasUnsavedRedisDraft.value))) void load();+ if (!loading.value && (!data.value || (loadedPreviewLimitBytes !== redisValuePreviewLimitBytes(props.previewLimitKiB) && !hasUnsavedRedisDraft.value))) void loadForDisplay();startRefreshTimers();});onDeactivated(() => {@@ -3877,6 +3903,12 @@ useUpdateBlocker(() => (hasUnsavedRedisDraft.value || editingTtl.value || saving</div></template>+ <!-- 读取失败:面板不能是空白,必须把失败原因显示出来并允许重试(issue #13114)。 -->+ <div v-else-if="loadError" data-redis-value-load-error class="flex-1 flex flex-col items-center justify-center gap-3 p-6 text-center">+ <div class="text-sm text-destructive break-words">{{ loadError }}</div>+ <Button data-redis-value-load-retry variant="outline" size="sm" :disabled="loading" @click="retryValueLoad">{{ t("grid.refresh") }}</Button>+ </div>+<DangerConfirmDialog v-model:open="showDeleteConfirm" :message="t('dangerDialog.deleteMessage')" :details="deleteDetails" :confirm-label="t('dangerDialog.deleteConfirm')" @confirm="confirmDelete" /><Dialog :open="showRenameKeyDialog" @update:open="handleRenameKeyDialogOpenChange">diff --git a/crates/dbx-driver-redis/src/lib.rs b/crates/dbx-driver-redis/src/lib.rsindex 315244be6c..f9d6863d4d 100644--- a/crates/dbx-driver-redis/src/lib.rs+++ b/crates/dbx-driver-redis/src/lib.rs@@ -3392,45 +3392,7 @@ wherelet data = match redis_type.as_str() {"string" => {- // GETRANGE in spans no larger than `STRING_PREVIEW_MAX_BYTES`: some- // Redis-compatible servers (e.g. TongRDS) reject a larger span, so a- // configured preview above the default budget is fetched in chunks- // (issue #11792). Filling the budget exactly means the value may- // continue — STRLEN settles that without materializing the rest in- // the backend or IPC layer.- let mut bytes: Vec<u8> = Vec::new();- let mut at_budget = false;- while bytes.len() < preview_limit_bytes {- let span = (preview_limit_bytes - bytes.len()).min(STRING_PREVIEW_MAX_BYTES);- let start = bytes.len() as i64;- let chunk: RedisRawValue = redis::cmd("GETRANGE")- .arg(key)- .arg(start)- .arg(start + span as i64 - 1)- .query_async(con)- .await- .map_err(|e| e.to_string())?;- let chunk = redis_value_to_bytes(chunk)- .ok_or_else(|| "Redis string payload is not byte-addressable".to_string())?;- let chunk_len = chunk.len();- bytes.extend_from_slice(&chunk);- if chunk_len < span {- break;- }- if bytes.len() >= preview_limit_bytes {- at_budget = true;- break;- }- }- let total_bytes = if at_budget {- redis::cmd("STRLEN").arg(key).query_async(con).await.ok()- } else {- Some(bytes.len() as u64)- };- let truncated = total_bytes.map_or(at_budget, |total| total > preview_limit_bytes as u64);- if truncated {- bytes.truncate(preview_limit_bytes);- }+ let (bytes, total_bytes, truncated) = read_string_preview(con, key, preview_limit_bytes).await?;RedisValueData::String { content: redis_blob_from_bytes(&bytes), total_bytes, truncated }}"list" => {@@ -3504,6 +3466,143 @@ where})}+/// Read the preview window of a Redis string value.+///+/// `GETRANGE` is used instead of `GET` so a large value is never pulled over+/// the wire in full. The window is requested optimistically first, the way+/// Redis clamps it to the value length, so reading a value stays a single+/// round trip for the servers that clamp.+///+/// Strict servers reject a window that reaches past the value instead of+/// clamping it: TongRDS answers `ERR 0-65536 is out of bounds` and the read+/// failed, which left the key detail empty for every string shorter than the+/// preview window (issue #13114). Such a rejection is answered with the exact+/// value length, and the windows are then requested inside it.+async fn read_string_preview<C>(+ con: &mut C,+ key: &[u8],+ preview_limit_bytes: usize,+) -> Result<(Vec<u8>, Option<u64>, bool), String>+where+ C: ConnectionLike + Send + Sync + Unpin,+{+ match read_string_windows(con, key, preview_limit_bytes, None).await {+ Ok(result) => Ok(result),+ Err(error) if !is_redis_out_of_bounds_error(&error) => Err(error),+ // The server refuses to clamp the window, so the value length+ // decides where a window may end.+ Err(_) => read_string_preview_by_length(con, key, preview_limit_bytes).await,+ }+}++/// Read a Redis string in windows that never reach past the value.+///+/// The value length decides where a window may end, so the same rejection+/// cannot come back — unless the value shrinks between the length read and+/// the window read, which is retried against the fresh length.+async fn read_string_preview_by_length<C>(+ con: &mut C,+ key: &[u8],+ preview_limit_bytes: usize,+) -> Result<(Vec<u8>, Option<u64>, bool), String>+where+ C: ConnectionLike + Send + Sync + Unpin,+{+ let known_length = redis_string_length(con, key).await;+ match read_string_windows(con, key, preview_limit_bytes, known_length).await {+ Ok(result) => Ok(result),+ Err(error) if is_redis_out_of_bounds_error(&error) => {+ // The value shrank between the length read and the window read.+ let known_length = redis_string_length(con, key).await;+ read_string_windows(con, key, preview_limit_bytes, known_length).await+ }+ Err(error) => Err(error),+ }+}++/// Read a Redis string in windows.+///+/// `known_length` is the value length reported by `STRLEN`; with it a window+/// never reaches past the value. Without it the window is requested+/// optimistically, the way Redis clamps it, and a short read ends the value.+async fn read_string_windows<C>(+ con: &mut C,+ key: &[u8],+ preview_limit_bytes: usize,+ known_length: Option<u64>,+) -> Result<(Vec<u8>, Option<u64>, bool), String>+where+ C: ConnectionLike + Send + Sync + Unpin,+{+ let limit = preview_limit_bytes as u64;+ let mut bytes: Vec<u8> = Vec::new();+ let mut at_budget = false;+ while (bytes.len() as u64) < limit {+ // Windows stay at most `STRING_PREVIEW_MAX_BYTES` wide so a large+ // configured budget is fetched in chunks (issue #11792).+ let span = match known_length {+ Some(total) => {+ let remaining = total.saturating_sub(bytes.len() as u64);+ if remaining == 0 {+ break;+ }+ remaining.min(limit - bytes.len() as u64).min(STRING_PREVIEW_MAX_BYTES as u64)+ }+ None => (limit - bytes.len() as u64).min(STRING_PREVIEW_MAX_BYTES as u64),+ };+ let start = bytes.len() as i64;+ let chunk: RedisRawValue = redis::cmd("GETRANGE")+ .arg(key)+ .arg(start)+ .arg(start + span as i64 - 1)+ .query_async(con)+ .await+ .map_err(|e| e.to_string())?;+ let chunk =+ redis_value_to_bytes(chunk).ok_or_else(|| "Redis string payload is not byte-addressable".to_string())?;+ let chunk_len = chunk.len() as u64;+ bytes.extend_from_slice(&chunk);+ if chunk_len < span {+ // The value ended before the window did.+ break;+ }+ if (bytes.len() as u64) >= limit {+ at_budget = true;+ break;+ }+ }+ let total_bytes = match known_length {+ Some(total) => Some(total),+ // The budget was filled exactly, so the value may continue — STRLEN+ // settles that without materializing the rest in the backend or IPC+ // layer.+ None if at_budget => redis_string_length(con, key).await,+ None => Some(bytes.len() as u64),+ };+ let truncated = total_bytes.map_or(at_budget, |total| total > limit);+ if truncated {+ bytes.truncate(preview_limit_bytes);+ }+ Ok((bytes, total_bytes, truncated))+}++/// Read the length of a Redis string value.+async fn redis_string_length<C>(con: &mut C, key: &[u8]) -> Option<u64>+where+ C: ConnectionLike + Send + Sync + Unpin,+{+ let length: i64 = redis::cmd("STRLEN").arg(key).query_async(con).await.ok()?;+ u64::try_from(length).ok()+}++/// Whether a server rejected a range because it reached past the value.+///+/// TongRDS answers `ERR 0-65536 is out of bounds`; Redis never rejects a+/// range for that reason.+fn is_redis_out_of_bounds_error(error: &str) -> bool {+ error.contains("out of bounds")+}+/// Read the complete raw payload for a Redis string-like key.////// The normal value path caps previews at the configured size. Downloads must@@ -8013,6 +8112,19 @@ mod tests {assert_eq!(entry_json["deliveries"], unsafe_value.to_string());}+ /// The `(start, end)` windows DBX requested with GETRANGE.+ fn getrange_windows(con: &FakeRedisConnection) -> Vec<(String, String)> {+ con.commands+ .iter()+ .filter(|packed| packed.contains("\r\nGETRANGE\r\n"))+ .map(|packed| {+ let parts: Vec<&str> = packed.split("\r\n").collect();+ let last = parts.len();+ (parts[last - 4].to_string(), parts[last - 2].to_string())+ })+ .collect()+ }+#[tokio::test]async fn string_value_uses_a_bounded_range_for_small_values() {let mut con = FakeRedisConnection::new(vec![bulk("string"), RedisRawValue::Int(-1), bulk("hello")]);@@ -8031,10 +8143,9 @@ mod tests {}#[tokio::test]- async fn string_value_range_stays_within_the_64kib_server_limit() {- // Some Redis-compatible servers reject a GETRANGE span above 64 KiB;- // the old budget + 1 request asked for 65537 bytes (TongRDS answered- // "0-65537 is out of bounds").+ async fn string_value_range_stays_within_the_64kib_window_limit() {+ // A window never exceeds 64 KiB, so a configured preview above that is+ // fetched in chunks (issue #11792).let mut con = FakeRedisConnection::new(vec![bulk("string"), RedisRawValue::Int(-1), bulk("hello")]);super::get_value(&mut con, b"message").await.unwrap();@@ -8045,6 +8156,94 @@ mod tests {assert!(!getrange.contains(&format!("\r\n$5\r\n{}\r\n", super::STRING_PREVIEW_MAX_BYTES)), "{getrange:?}");}+ #[tokio::test]+ async fn string_value_falls_back_to_the_value_length_when_the_server_rejects_the_window() {+ // Issue #13114: TongRDS does not clamp a GETRANGE window that reaches+ // past the value the way Redis does: it answers "ERR 0-65536 is out of+ // bounds", which left the key detail empty for every string shorter+ // than the preview window. The read has to fall back to the exact+ // value length.+ let out_of_bounds = redis::RedisError::from((+ redis::ErrorKind::Server(redis::ServerErrorKind::ResponseError),+ "ERR",+ "0-65536 is out of bounds".to_string(),+ ));+ let mut con = FakeRedisConnection::with_results(vec![+ Ok(bulk("string")),+ Ok(RedisRawValue::Int(-1)),+ Err(out_of_bounds),+ Ok(RedisRawValue::Int(3)),+ Ok(bulk("123")),+ ]);++ let value = super::get_value(&mut con, b"123").await.unwrap();++ let RedisValueData::String { content, total_bytes, truncated } = &value.data else {+ panic!("expected a String value");+ };+ assert_eq!(redis_blob_display_text(content), "123");+ assert_eq!(*total_bytes, Some(3));+ assert!(!truncated);+ // The retry asks for the value instead of the whole preview window.+ assert_eq!(+ getrange_windows(&con),+ vec![("0".to_string(), "65535".to_string()), ("0".to_string(), "2".to_string())]+ );+ assert_eq!(con.command_count("GETRANGE"), 2);+ assert_eq!(con.command_count("STRLEN"), 1);+ }++ #[tokio::test]+ async fn string_value_retries_when_the_value_shrinks() {+ // The value was 100 bytes when its length was read and 10 bytes when+ // the window was requested. The read is retried against the fresh+ // length instead of failing.+ let out_of_bounds = || {+ redis::RedisError::from((+ redis::ErrorKind::Server(redis::ServerErrorKind::ResponseError),+ "ERR",+ "0-100 is out of bounds".to_string(),+ ))+ };+ let mut con = FakeRedisConnection::with_results(vec![+ Ok(bulk("string")),+ Ok(RedisRawValue::Int(-1)),+ Err(out_of_bounds()),+ Ok(RedisRawValue::Int(100)),+ Err(out_of_bounds()),+ Ok(RedisRawValue::Int(10)),+ Ok(bulk("0123456789")),+ ]);++ let value = super::get_value(&mut con, b"message").await.unwrap();++ let RedisValueData::String { content, total_bytes, truncated } = &value.data else {+ panic!("expected a String value");+ };+ assert_eq!(redis_blob_display_text(content), "0123456789");+ assert_eq!(*total_bytes, Some(10));+ assert!(!truncated);+ assert_eq!(con.command_count("GETRANGE"), 3);+ assert_eq!(con.command_count("STRLEN"), 2);+ }++ #[tokio::test]+ async fn string_value_reports_other_errors_without_retrying() {+ let denied = redis::RedisError::from((+ redis::ErrorKind::Server(redis::ServerErrorKind::ResponseError),+ "ERR",+ "NOPERM this user has no permissions to run the 'getrange' command".to_string(),+ ));+ let mut con =+ FakeRedisConnection::with_results(vec![Ok(bulk("string")), Ok(RedisRawValue::Int(-1)), Err(denied)]);++ let error = super::get_value(&mut con, b"message").await.unwrap_err();++ assert!(error.contains("NOPERM"), "{error}");+ assert_eq!(con.command_count("GETRANGE"), 1);+ assert_eq!(con.command_count("STRLEN"), 0);+ }+#[tokio::test]async fn string_value_at_the_preview_budget_is_not_flagged_truncated() {let payload = vec![b'a'; super::STRING_PREVIEW_MAX_BYTES];@@ -8128,7 +8327,7 @@ mod tests {assert_eq!(con.command_count("GET"), 0);assert_eq!(con.command_count("STRLEN"), 0);}- // A configured limit above the 64 KiB span cap is fetched in 64 KiB chunks,+ // A configured limit above the 64 KiB window limit is fetched in 64 KiB chunks,// and filling the budget exactly asks STRLEN for the real size.let limit = 128 * 1024;let mut con = FakeRedisConnection::new(vec![@@ -8154,6 +8353,39 @@ mod tests {assert_eq!(con.command_count("STRLEN"), 1);}+ /// Live check for servers that reject a GETRANGE window that reaches past+ /// the value. TongRDS answers `ERR 0-65536 is out of bounds` there, which+ /// left the key detail empty, so the preview has to read the value and+ /// report its real size.+ ///+ /// Set `DBX_TEST_REDIS_STRING_KEY` to read an existing key instead of+ /// writing a temporary one.+ #[tokio::test]+ #[ignore = "requires a disposable Redis via DBX_TEST_REDIS_URL"]+ async fn string_preview_reads_the_value_on_strict_range_servers() {+ let url = std::env::var("DBX_TEST_REDIS_URL").expect("DBX_TEST_REDIS_URL");+ let existing = std::env::var("DBX_TEST_REDIS_STRING_KEY").ok();+ let key = existing.clone().unwrap_or_else(|| "dbx-string-preview-probe".to_string());+ let mut con = super::connect(&url, std::time::Duration::from_secs(5)).await.unwrap();+ if existing.is_none() {+ let _: () = redis::cmd("SET").arg(&key).arg("123").query_async(&mut con).await.unwrap();+ }+ let expected_len: i64 = redis::cmd("STRLEN").arg(&key).query_async(&mut con).await.unwrap();++ let value = super::get_value(&mut con, key.as_bytes()).await.unwrap();++ let RedisValueData::String { content, total_bytes, truncated } = value.data else {+ panic!("expected a String value");+ };+ assert_eq!(total_bytes, Some(expected_len as u64));+ assert!(!truncated);+ let decoded = base64::engine::general_purpose::STANDARD.decode(&content.raw_base64).unwrap();+ assert_eq!(decoded.len() as u64, expected_len as u64);+ if existing.is_none() {+ let _: u64 = redis::cmd("DEL").arg(&key).query_async(&mut con).await.unwrap();+ }+ }+#[tokio::test]async fn value_preview_limit_rejects_invalid_sizes_before_redis_io() {for limit in [0, 1023, super::VALUE_PREVIEW_MAX_BYTES + 1, usize::MAX] {