{"record":{"id":"b665e60bb180fc94","repo":"stalwartlabs/stalwart","slug":"failed-to-scan-keys","errorCode":null,"errorMessage":"Failed to scan keys","messagePattern":"Failed to scan keys","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/manager/console.rs","lineNumber":88,"sourceCode":"                                AnyKey {\n                                    subspace: to_subspace,\n                                    key: to_key.collect::<Vec<_>>(),\n                                },\n                            )\n                            .set_values(\n                                ![SUBSPACE_INDEXES, SUBSPACE_REGISTRY_IDX].contains(&from_subspace),\n                            ),\n                            |key, value| {\n                                print!(\"{}\", char::from(from_subspace));\n                                print_escaped(key);\n                                print!(\" : \");\n                                print_escaped(value);\n                                println!();\n                                Ok(true)\n                            },\n                        )\n                        .await\n                        .expect(\"Failed to scan keys\");\n                }\n            }\n            \"delete\" => match (parts.get(1), parts.get(2)) {\n                (Some(from_key), Some(to_key)) => {\n                    if let (Some(from_key), Some(to_key)) = (parse_key(from_key), parse_key(to_key))\n                    {\n                        let mut from_key = from_key.into_iter();\n                        let mut to_key = to_key.into_iter();\n\n                        let from_key = AnyKey {\n                            subspace: from_key.next().unwrap(),\n                            key: from_key.collect::<Vec<_>>(),\n                        };\n                        let to_key = AnyKey {\n                            subspace: to_key.next().unwrap(),\n                            key: to_key.collect::<Vec<_>>(),\n                        };\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/stalwartlabs/stalwart/blob/e96200385781a6a9995a8b839ac27d6c75a983ee/crates/common/src/manager/console.rs#L70-L106","documentation":"This panic comes from `store.iterate(...).await.expect(\"Failed to scan keys\")` inside `store_console`'s interactive `scan <from_key> <to_key>` command. The store's `iterate` call returned an `Err`, i.e. the underlying storage backend (FoundationDB, PostgreSQL, MySQL, SQLite, RocksDB, etc.) failed while opening a cursor/range scan over the key range, so the console aborts instead of printing entries.","triggerScenarios":"Running `scan <from_key> <to_key>` in the Stalwart store console when the backend connection is down or times out, the store is unavailable (network partition, DB restarted), the key range is rejected by the backend, or the driver returns an error mid-iteration.","commonSituations":"Administrators debugging a store whose database was stopped or unreachable (wrong host/port in config, DB container not running); expired DB credentials; network/firewall issues between the console process and the datastore; backend driver errors surfaced only during range scans.","solutions":["Check the underlying store is reachable: verify store host/port/credentials in the config and that the DB server is running.","Read the error message printed by the panic (it wraps the backend error) to identify the driver-specific failure and fix it accordingly.","Test connectivity from the server host (e.g. psql/mysql client, fdb status) before retrying the scan.","Retry the scan command after restoring the connection; if it persists, narrow the key range — an extremely large range can hit backend timeouts."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before scanning, verify store availability\nif matches!(store, Store::None) {\n    eprintln!(\"No store available. Verify your configuration.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"match store.iterate(params, callback).await {\n    Ok(()) => {}\n    Err(err) => eprintln!(\"Failed to scan keys: {}\", err), // handle instead of .expect\n}","preventionTips":["Confirm the store backend is up before starting console maintenance sessions.","Validate store host/port/credentials in the config first.","Keep key ranges small; narrow ranges reduce backend scan timeouts.","Check DB connectivity with a native client when scans start failing."],"tags":["database","storage","console","range-scan","panic"],"backgroundTag":"database-query-failed","analyzedSha":"e96200385781a6a9995a8b839ac27d6c75a983ee","analyzedAt":"2026-09-06T22:07:17.982Z","contentChangedAt":"2026-09-06T22:07:17.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}